| Conditions | 6 |
| Paths | 5 |
| Total Lines | 21 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | public static function containsTrait(ReflectionClass $reflection, string $class): bool |
||
| 18 | { |
||
| 19 | if (!trait_exists($class)) { |
||
| 20 | throw new InvalidArgumentException(sprintf('Class "%s" is not a valid trait', $class)); |
||
| 21 | } |
||
| 22 | |||
| 23 | do { |
||
| 24 | $traits = $reflection->getTraitNames(); |
||
| 25 | |||
| 26 | if (\in_array($class, $traits, true)) { |
||
| 27 | return true; |
||
| 28 | } |
||
| 29 | |||
| 30 | foreach ($reflection->getTraits() as $reflTraits) { |
||
| 31 | if (static::containsTrait($reflTraits, $class)) { |
||
| 32 | return true; |
||
| 33 | } |
||
| 34 | } |
||
| 35 | } while ($reflection = $reflection->getParentClass()); |
||
| 36 | |||
| 37 | return false; |
||
| 38 | } |
||
| 40 |