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

nepada / file-upload-control / 11627792231

28 Oct 2024 11:42AM UTC coverage: 81.674%. Remained the same
11627792231

push

github

xificurk
FE: fix binding to latest nette-forms.js

722 of 884 relevant lines covered (81.67%)

0.82 hits per line

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
use Stringable;
10

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

17
    protected FakeUploadControl $fakeUploadControl;
18

19
    private Rules $rules;
20

21
    /**
22
     * @return $this
23
     */
24
    public function addRule(callable|string $validator, string|Stringable|null $errorMessage = null, mixed $arg = null): static
1✔
25
    {
26
        $this->rules->addRule($validator, $errorMessage, $arg);
1✔
27
        return $this;
1✔
28
    }
29

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

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

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

53
    /**
54
     * @return $this
55
     */
56
    public function setRequired(string|Stringable|bool $value = true): static
1✔
57
    {
58
        $this->rules->setRequired($value);
1✔
59
        return $this;
1✔
60
    }
61

62
    public function isRequired(): bool
63
    {
64
        return $this->rules->isRequired();
1✔
65
    }
66

67
    public function validate(): void
68
    {
69
        if ($this->isDisabled()) {
1✔
70
            return;
×
71
        }
72
        $this->cleanErrors();
1✔
73
        $this->rules->validate();
1✔
74
    }
1✔
75

76
    private function initializeValidation(FileUploadControl $control): void
1✔
77
    {
78
        $this->fakeUploadControl = new FakeUploadControl($control);
1✔
79
        $this->rules = new Rules($this->fakeUploadControl);
1✔
80
    }
1✔
81

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