| Total Complexity | 5 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | final class FilterFactory |
||
| 28 | { |
||
| 29 | /** |
||
| 30 | * @const array |
||
| 31 | */ |
||
| 32 | const DEFAULT_FILTERS = [ |
||
| 33 | ExtensionFilter::class, |
||
| 34 | MediaTypeFilter::class |
||
| 35 | ]; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param ContainerInterface $container |
||
| 39 | * |
||
| 40 | * @return FilterInterface |
||
| 41 | */ |
||
| 42 | public function __invoke(ContainerInterface $container): FilterInterface |
||
| 43 | { |
||
| 44 | if ($container->has(FilterAggregator::class)) { |
||
| 45 | return $container->get(FilterAggregator::class); |
||
| 46 | } |
||
| 47 | |||
| 48 | $filters = []; |
||
| 49 | foreach (self::DEFAULT_FILTERS as $filter) { |
||
| 50 | if (!$container->has($filter)) { |
||
| 51 | continue; |
||
| 52 | } |
||
| 53 | |||
| 54 | $filters[] = $container->get($filter); |
||
| 55 | } |
||
| 56 | |||
| 57 | return $this->fromFilters(...$filters); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @param FilterInterface ...$filters |
||
| 62 | * |
||
| 63 | * @return FilterAggregator |
||
| 64 | */ |
||
| 65 | public function fromFilters(FilterInterface ...$filters): FilterAggregator |
||
| 68 | } |
||
| 69 | } |
||
| 70 |