• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nepada / file-upload-control / 6449927556

08 Oct 2023 08:55PM UTC coverage: 90.363% (+0.05%) from 90.309%
6449927556

push

github

xificurk
Drop useless dev dependency

647 of 716 relevant lines covered (90.36%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.21
/src/FileUploadControl/Validation/UploadValidation.php
1
<?php
2
declare(strict_types = 1);
3

4
namespace Nepada\FileUploadControl\Validation;
5

6
use Nepada\FileUploadControl\FileUploadControl;
7
use Nette\Forms\Control;
8
use Nette\Forms\Rules;
9
use Nette\Utils\Html;
10

11
/**
12
 * @internal
13
 */
14
trait UploadValidation
15
{
16

17
    protected FakeUploadControl $fakeUploadControl;
18

19
    private Rules $rules;
20

21
    /**
22
     * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
23
     * @param callable|string $validator
24
     * @param string|Html|null $errorMessage
25
     * @return $this
26
     */
27
    public function addRule($validator, $errorMessage = null, mixed $arg = null): static
1✔
28
    {
29
        $this->rules->addRule($validator, $errorMessage, $arg);
1✔
30
        return $this;
1✔
31
    }
32

33
    /**
34
     * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
35
     * @param callable|string $validator
36
     */
37
    public function addCondition($validator, mixed $value = null): Rules
38
    {
39
        return $this->rules->addCondition($validator, $value);
×
40
    }
41

42
    /**
43
     * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
44
     * @param callable|string $validator
45
     */
46
    public function addConditionOn(Control $control, $validator, mixed $value = null): Rules
47
    {
48
        return $this->rules->addConditionOn($control, $validator, $value);
×
49
    }
50

51
    public function getRules(): Rules
52
    {
53
        return $this->rules;
1✔
54
    }
55

56
    /**
57
     * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
58
     * @param bool|string|Html $value
59
     * @return $this
60
     */
61
    public function setRequired($value = true): static
1✔
62
    {
63
        $this->rules->setRequired($value);
1✔
64
        return $this;
1✔
65
    }
66

67
    public function isRequired(): bool
68
    {
69
        return $this->rules->isRequired();
1✔
70
    }
71

72
    public function validate(): void
73
    {
74
        if ($this->isDisabled()) {
1✔
75
            return;
×
76
        }
77
        $this->cleanErrors();
1✔
78
        $this->rules->validate();
1✔
79
    }
1✔
80

81
    private function initializeValidation(FileUploadControl $control): void
1✔
82
    {
83
        $this->fakeUploadControl = new FakeUploadControl($control);
1✔
84
        $this->rules = new Rules($this->fakeUploadControl);
1✔
85
    }
1✔
86

87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc