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

contributte / forms-bootstrap / #71

22 Apr 2024 10:51AM UTC coverage: 83.039%. Remained the same
#71

Pull #95

github

dakorpar
compativility with nette forms 3.2.2
Pull Request #95: Nette forms3.2.2

705 of 849 relevant lines covered (83.04%)

5.64 hits per line

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

73.33
/src/Traits/ChoiceInputTrait.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\FormsBootstrap\Traits;
4

5
/**
6
 * Trait ChoiceInputTrait.
7
 * Provides basic functionality for inputs where one of more than one predefined values are possible.
8
 *
9
 * @property bool|array|null $disabled
10
 * @method int|string|array getValue()
11
 */
12
trait ChoiceInputTrait
13
{
14

15
        /**
16
         * Check if whole control is disabled.
17
         * This is false if only a set of values is disabled
18
         */
19
        protected function isControlDisabled(): bool
20
        {
21
                if (is_bool($this->disabled)) {
8✔
22
                        return $this->disabled;
8✔
23
                }
24

25
                return false;
×
26
        }
27

28
        /**
29
         * Check if a specific value is disabled. If whole control is disabled, returns false.
30
         *
31
         * @param mixed $value value to check for
32
         */
33
        protected function isValueDisabled($value): bool
34
        {
35
                $disabled = $this->disabled;
4✔
36
                if (is_array($disabled)) {
4✔
37
                        return isset($disabled[$value]) && $disabled[$value];
×
38
                } elseif (!is_bool($disabled)) {
4✔
39
                        return $disabled === $value;
×
40
                }
41

42
                return false;
4✔
43
        }
44

45
        /**
46
         * @param mixed $value
47
         */
48
        protected function isValueSelected($value): bool
49
        {
50
                $val = $this->getValue();
4✔
51
                if ($value === null) {
4✔
52
                        return false;
×
53
                }
54

55
                if (is_array($val)) {
4✔
56
                        return in_array($value, $val);
2✔
57
                }
58

59
                return ((string) $value) === ((string) $val);
2✔
60
        }
61

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