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