Total Complexity | 6 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Coverage | 91.67% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | trait QueueableTrait |
||
11 | { |
||
12 | /** |
||
13 | * @psalm-param class-string|object $class |
||
14 | */ |
||
15 | 6 | public function findQueueable($object): ?Queueable |
|
16 | { |
||
17 | 6 | $reflection = new \ReflectionClass($object); |
|
18 | |||
19 | 6 | if ($reflection->isInterface()) { |
|
20 | return null; |
||
21 | } |
||
22 | |||
23 | 6 | if ($reflection->implementsInterface(QueueableInterface::class)) { |
|
24 | 3 | return $this->createQueueable($reflection, $object); |
|
25 | } |
||
26 | |||
27 | 3 | return (new Factory())->create()->firstClassMetadata($reflection, Queueable::class); |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * @psalm-param class-string|object $object |
||
32 | */ |
||
33 | 3 | private function createQueueable(\ReflectionClass $reflection, $object): Queueable |
|
42 | } |
||
43 | } |
||
44 |