Conditions | 4 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 3 |
CRAP Score | 8.7414 |
Changes | 0 |
1 | <?php |
||
25 | 6 | public function validate(ValidationContext $context) |
|
26 | { |
||
27 | 6 | if (empty($this->value)) { |
|
28 | throw $this->createValidationException( |
||
29 | $context, |
||
30 | 'you must provide a class as value. Example @Slumber\AsObject( SomeClass::class )' |
||
31 | ); |
||
32 | } |
||
33 | |||
34 | // NOTICE: we also accept interfaces here, as the interface can define a Slumber\Polymorphic |
||
35 | 6 | if (! class_exists($this->value) && ! interface_exists($this->value)) { |
|
36 | throw $this->createValidationException( |
||
37 | $context, |
||
38 | "you provided the non-existing class '$this->value'" |
||
39 | ); |
||
51 |