| Conditions | 6 |
| Paths | 6 |
| Total Lines | 30 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 6.5625 |
| Changes | 0 | ||
| 1 | <?php namespace Cairns\Radiate\Registry; |
||
| 9 | 1 | public function register($listener) |
|
| 10 | { |
||
| 11 | 1 | $class = new ReflectionClass($listener); |
|
| 12 | |||
| 13 | 1 | $methods = $class->getMethods(); |
|
| 14 | |||
| 15 | 1 | foreach ($methods as $method) { |
|
| 16 | 1 | if (! $method->isPublic()) { |
|
| 17 | continue; |
||
| 18 | } |
||
| 19 | |||
| 20 | 1 | if ($method->getNumberOfParameters() !== 1) { |
|
| 21 | continue; |
||
| 22 | } |
||
| 23 | |||
| 24 | 1 | if ($method->getNumberOfRequiredParameters() !== 1) { |
|
| 25 | continue; |
||
| 26 | } |
||
| 27 | |||
| 28 | 1 | $param = $method->getParameters()[0]; |
|
| 29 | |||
| 30 | 1 | $type = $param->getType(); |
|
| 31 | |||
| 32 | 1 | if ($type->isBuiltin()) { |
|
| 33 | continue; |
||
| 34 | } |
||
| 35 | |||
| 36 | 1 | $this->listeners[(string) $type][] = $listener; |
|
| 37 | } |
||
| 38 | 1 | } |
|
| 39 | |||
| 47 |