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

nepada / file-upload-control / 9327437708

pending completion
9327437708

Pull #156

github

web-flow
Merge 92839108e into 46a12c798
Pull Request #156: Update mockery/mockery requirement from 1.6.11 to 1.6.12

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

90.0
/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

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

16
    protected FakeUploadControl $fakeUploadControl;
17

18
    private Rules $rules;
19

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

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

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

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

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

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

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

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

86
}
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