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

nepada / form-renderer / 6495512058

12 Oct 2023 12:18PM UTC coverage: 96.992%. Remained the same
6495512058

push

github

xificurk
CI fix: ignore legacy IE rendering bug fix in HTML output

258 of 266 relevant lines covered (96.99%)

0.97 hits per line

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

100.0
/src/FormRenderer/Filters/ValidationClassFilter.php
1
<?php
2
declare(strict_types = 1);
3

4
namespace Nepada\FormRenderer\Filters;
5

6
use Nette;
7

8
final class ValidationClassFilter
1✔
9
{
10

11
    use Nette\SmartObject;
12

13
    private ?string $invalidClass;
14

15
    private ?string $validClass;
16

17
    public function __construct(?string $invalidClass, ?string $validClass)
18
    {
19
        $this->invalidClass = $invalidClass;
1✔
20
        $this->validClass = $validClass;
1✔
21
    }
1✔
22

23
    public function __invoke(Nette\Forms\Control $control): ?string
24
    {
25
        if (count($control->getErrors()) > 0) {
1✔
26
            return $this->invalidClass;
1✔
27
        }
28

29
        if ($this->isFilled($control)) {
1✔
30
            return $this->validClass;
1✔
31
        }
32

33
        return null;
1✔
34
    }
35

36
    private function isFilled(Nette\Forms\Control $control): bool
37
    {
38
        if ($control instanceof Nette\Forms\Controls\TextInput && $control->getControlPrototype()->type === 'password') {
1✔
39
            return false;
1✔
40
        }
41

42
        if ($control instanceof Nette\Forms\Controls\BaseControl || method_exists($control, 'isFilled')) {
1✔
43
            return $control->isFilled();
1✔
44
        }
45

46
        $value = $control->getValue();
1✔
47
        return $value !== null && $value !== [] && $value !== '';
1✔
48
    }
49

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