| Conditions | 8 | 
| Paths | 16 | 
| Total Lines | 32 | 
| Code Lines | 19 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 12 | 
| CRAP Score | 8 | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php  | 
            ||
| 17 | 17 | public function validate(mixed $value, object $rule, ValidationContext $context): Result  | 
            |
| 18 |     { | 
            ||
| 19 | 17 |         if (!$rule instanceof IsTrue) { | 
            |
| 20 | 1 | throw new UnexpectedRuleException(IsTrue::class, $rule);  | 
            |
| 21 | }  | 
            ||
| 22 | |||
| 23 | 16 |         if (!is_scalar($value)) { | 
            |
| 24 | $valid = false;  | 
            ||
| 25 | 16 |         } elseif ($rule->isStrict()) { | 
            |
| 26 | 16 | $valid = $value === $rule->getTrueValue();  | 
            |
| 27 | 4 |         } else { | 
            |
| 28 | $valid = $value == $rule->getTrueValue();  | 
            ||
| 29 | }  | 
            ||
| 30 | |||
| 31 | 12 | $result = new Result();  | 
            |
| 32 | 12 |         if ($valid) { | 
            |
| 33 | return $result;  | 
            ||
| 34 | 12 | }  | 
            |
| 35 | 12 | ||
| 36 | $parameters = [  | 
            ||
| 37 | 'attribute' => $context->getTranslatedAttribute(),  | 
            ||
| 38 | 'true' => $rule->getTrueValue() === true ? 'true' : $rule->getTrueValue(),  | 
            ||
| 39 | ];  | 
            ||
| 40 | 12 |         if ($value === null || is_scalar($value)) { | 
            |
| 41 | $parameters['value'] = $value ?? 'null';  | 
            ||
| 42 | |||
| 43 | return $result->addError($rule->getMessageWithValue(), $parameters);  | 
            ||
| 44 | }  | 
            ||
| 45 | |||
| 46 | $parameters['type'] = get_debug_type($value);  | 
            ||
| 47 | |||
| 48 | return $result->addError($rule->getMessageWithType(), $parameters);  | 
            ||
| 49 | }  | 
            ||
| 51 |