Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
93.33% |
14 / 15 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| ReflectionClassList | |
93.33% |
14 / 15 |
|
66.67% |
2 / 3 |
3.00 | |
0.00% |
0 / 1 |
| offsetGet | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| toStringArray | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| filterOnApieContext | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Core\Lists; |
| 3 | |
| 4 | use Apie\Core\Context\ApieContext; |
| 5 | use ReflectionClass; |
| 6 | |
| 7 | /** |
| 8 | * @extends ItemList<ReflectionClass<object>> |
| 9 | */ |
| 10 | final class ReflectionClassList extends ItemList |
| 11 | { |
| 12 | /** |
| 13 | * @return ReflectionClass<object> |
| 14 | */ |
| 15 | public function offsetGet(mixed $offset): ReflectionClass |
| 16 | { |
| 17 | return parent::offsetGet($offset); |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * @return string[] |
| 22 | */ |
| 23 | public function toStringArray(): array |
| 24 | { |
| 25 | return array_map( |
| 26 | function (ReflectionClass $refl) { |
| 27 | return $refl->getName(); |
| 28 | }, |
| 29 | $this->internal |
| 30 | ); |
| 31 | } |
| 32 | |
| 33 | public function filterOnApieContext(ApieContext $apieContext, bool $runtimeChecks = true): self |
| 34 | { |
| 35 | $clone = new ReflectionClassList(); |
| 36 | $clone->internal = array_values(array_filter( |
| 37 | $this->internal, |
| 38 | function (ReflectionClass $item) use ($apieContext, $runtimeChecks) { |
| 39 | return $apieContext->appliesToContext($item, $runtimeChecks); |
| 40 | } |
| 41 | )); |
| 42 | return $clone; |
| 43 | } |
| 44 | } |