|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * This file is part of the Nexus framework. |
| 7 | + * |
| 8 | + * (c) John Paul E. Balandan, CPA <[email protected]> |
| 9 | + * |
| 10 | + * For the full copyright and license information, please view |
| 11 | + * the LICENSE file that was distributed with this source code. |
| 12 | + */ |
| 13 | + |
| 14 | +namespace Nexus\Api; |
| 15 | + |
| 16 | +use ApiGen\Index\NamespaceIndex; |
| 17 | +use ApiGen\Info\ClassLikeInfo; |
| 18 | +use ApiGen\Renderer\Filter; |
| 19 | + |
| 20 | +final class RendererFilter extends Filter |
| 21 | +{ |
| 22 | + public function filterNamespacePage(NamespaceIndex $namespace): bool |
| 23 | + { |
| 24 | + foreach ($namespace->children as $child) { |
| 25 | + if ($this->filterNamespacePage($child)) { |
| 26 | + return true; |
| 27 | + } |
| 28 | + } |
| 29 | + |
| 30 | + foreach ($namespace->class as $class) { |
| 31 | + if ($this->filterClassLikePage($class)) { |
| 32 | + return true; |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + foreach ($namespace->interface as $interface) { |
| 37 | + if ($this->filterClassLikePage($interface)) { |
| 38 | + return true; |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + foreach ($namespace->trait as $trait) { |
| 43 | + if ($this->filterClassLikePage($trait)) { |
| 44 | + return true; |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + foreach ($namespace->enum as $enum) { |
| 49 | + if ($this->filterClassLikePage($enum)) { |
| 50 | + return true; |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + foreach ($namespace->exception as $exception) { |
| 55 | + if ($this->filterClassLikePage($exception)) { |
| 56 | + return true; |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + foreach ($namespace->function as $function) { |
| 61 | + if ($this->filterFunctionPage($function)) { |
| 62 | + return true; |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + return false; |
| 67 | + } |
| 68 | + |
| 69 | + public function filterClassLikePage(ClassLikeInfo $classLike): bool |
| 70 | + { |
| 71 | + return $this->isClassRendered($classLike); |
| 72 | + } |
| 73 | + |
| 74 | + private function isClassRendered(ClassLikeInfo $classLike): bool |
| 75 | + { |
| 76 | + $name = $classLike->name->full; |
| 77 | + |
| 78 | + return str_starts_with($name, 'Nexus\\'); |
| 79 | + } |
| 80 | +} |
0 commit comments