Total Complexity | 7 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class QueueableDetector |
||
11 | { |
||
12 | private ReaderInterface $reader; |
||
13 | |||
14 | 8 | public function __construct(ReaderInterface $reader) |
|
15 | { |
||
16 | 8 | $this->reader = $reader; |
|
17 | } |
||
18 | |||
19 | /** |
||
20 | * @psalm-param class-string|object $object |
||
21 | */ |
||
22 | 8 | public function isQueueable($object): bool |
|
23 | { |
||
24 | 8 | $reflection = new \ReflectionClass($object); |
|
25 | |||
26 | 8 | if ($reflection->implementsInterface(QueueableInterface::class)) { |
|
27 | 3 | return true; |
|
28 | } |
||
29 | |||
30 | 5 | return $this->reader->firstClassMetadata($reflection, Queueable::class) !== null; |
|
31 | } |
||
32 | |||
33 | /** |
||
34 | * @psalm-param class-string|object $object |
||
35 | */ |
||
36 | 8 | public function getQueue($object): ?string |
|
50 | } |
||
51 | } |
||
52 |