Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
77.78% |
7 / 9 |
|
60.00% |
3 / 5 |
CRAP | |
0.00% |
0 / 1 |
| Boolean | |
77.78% |
7 / 9 |
|
60.00% |
3 / 5 |
6.40 | |
0.00% |
0 / 1 |
| __construct | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
2.03 | |||
| __toString | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| unwrap | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| json | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isset | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray\Value; |
| 6 | |
| 7 | use Cosray\Field\Field; |
| 8 | use Cosray\Field\Owner; |
| 9 | |
| 10 | class Boolean extends Value |
| 11 | { |
| 12 | public readonly bool $value; |
| 13 | |
| 14 | public function __construct(Owner $owner, Field $field, ValueContext $context) |
| 15 | { |
| 16 | parent::__construct($owner, $field, $context); |
| 17 | |
| 18 | $value = $this->value(); |
| 19 | |
| 20 | if (is_bool($value)) { |
| 21 | $this->value = $value; |
| 22 | } else { |
| 23 | $this->value = false; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | public function __toString(): string |
| 28 | { |
| 29 | return (string) $this->value; |
| 30 | } |
| 31 | |
| 32 | public function unwrap(): bool |
| 33 | { |
| 34 | return $this->value; |
| 35 | } |
| 36 | |
| 37 | public function json(): mixed |
| 38 | { |
| 39 | return $this->value; |
| 40 | } |
| 41 | |
| 42 | public function isset(): bool |
| 43 | { |
| 44 | return true; |
| 45 | } |
| 46 | } |