|
17 | 17 | use Chevere\VarDump\Interfaces\VarDumperInterface;
|
18 | 18 | use InvalidArgumentException;
|
19 | 19 | use function Chevere\Message\message;
|
| 20 | +use function Chevere\Parameter\getType; |
20 | 21 |
|
21 | 22 | trait ProcessorTrait
|
22 | 23 | {
|
@@ -64,16 +65,20 @@ public function maxDepthReached(): string
|
64 | 65 | private function assertType(): void
|
65 | 66 | {
|
66 | 67 | $type = new Type($this->type());
|
67 |
| - if (! $type->validate($this->varDumper->dumpable()->var())) { |
68 |
| - throw new InvalidArgumentException( |
69 |
| - (string) message( |
70 |
| - 'Instance of `%className%` expects a type `%expected%` for the return value of `%method%`, type `%provided%` returned', |
71 |
| - className: static::class, |
72 |
| - expected: $this->type(), |
73 |
| - method: $this->varDumper::class . '::var()', |
74 |
| - provided: get_debug_type($this->varDumper->dumpable()->var()), |
75 |
| - ) |
76 |
| - ); |
| 68 | + if ($type->validate($this->varDumper->dumpable()->var())) { |
| 69 | + return; |
77 | 70 | }
|
| 71 | + $provided = getType($this->varDumper->dumpable()->var()); |
| 72 | + $method = $this->varDumper::class . '::var()'; |
| 73 | + |
| 74 | + throw new InvalidArgumentException( |
| 75 | + (string) message( |
| 76 | + 'Instance of `%className%` expects type `%expected%` for the return value of `%method%`, type `%provided%` returned', |
| 77 | + className: static::class, |
| 78 | + expected: $this->type(), |
| 79 | + method: $method, |
| 80 | + provided: $provided, |
| 81 | + ) |
| 82 | + ); |
78 | 83 | }
|
79 | 84 | }
|
0 commit comments