| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3.0123 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | 4 | public function validate(mixed $value, object $rule, ValidationContext $context): Result |
|
| 24 | { |
||
| 25 | 4 | if (!$rule instanceof TableExistsRule) { |
|
| 26 | throw new UnexpectedRuleException(TableExistsRule::class, $rule); |
||
| 27 | } |
||
| 28 | |||
| 29 | 4 | $result = new Result(); |
|
| 30 | |||
| 31 | 4 | $tableSchema = $this->connection->getTableSchema($value); |
|
| 32 | |||
| 33 | 4 | if ($tableSchema === null) { |
|
| 34 | 1 | $result->addError(sprintf('Table "%s" does not exist.', $value)); |
|
| 35 | 1 | return $result; |
|
| 36 | } |
||
| 37 | |||
| 38 | 3 | return $result; |
|
| 39 | } |
||
| 41 |