Conditions | 5 |
Paths | 12 |
Total Lines | 27 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | public function handle($message, callable $next) |
||
29 | { |
||
30 | $this->ensureTypeOfMessage($message); |
||
31 | |||
32 | try { |
||
33 | $handler = $this->handlerClassResolver->resolve($message); |
||
34 | $metadata = Validator::getMetadataForClass(get_class($message)); |
||
35 | $classMetadata = null; |
||
36 | |||
37 | if ($metadata !== null) { |
||
38 | /** @var ClassMetadata $classMetadata */ |
||
39 | $classMetadata = $metadata->getRootClassMetadata(); |
||
|
|||
40 | } |
||
41 | |||
42 | $handler($message, $classMetadata); |
||
43 | } catch (NotFoundException $e) { |
||
44 | // NotFoundException::handlerMethodNameForObject |
||
45 | // NotFoundException::methodForObject |
||
46 | if ($e->getCode() == 3 || $e->getCode() == 7) { |
||
47 | throw $e; |
||
48 | } |
||
49 | } |
||
50 | |||
51 | Validator::assert($message); |
||
52 | |||
53 | return $next($message); |
||
54 | } |
||
55 | } |
||
56 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: