Lines
100.00%
7 / 7
Methods
100.00%
7 / 7
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| buildLinearTree | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| buildAdminCategoryTree | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| getChildren | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| getChildNodes | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| getLevelOf | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| getNodes | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| 28 | final class CategoryTreeFacade | |
| 29 | { | |
| 30 | public function __construct( | |
| 31 | private TreeBuilder $treeBuilder = new TreeBuilder(), | |
| 32 | ) { | |
| 33 | } | |
| 34 | ||
| 35 | /** | |
| 36 | * Builds a linear category tree with indentation. | |
| 37 | * | |
| 38 | * @param array<int, array<string, mixed>> $categories | |
| 39 | * @return array<int, array<string, mixed>> | |
| 40 | */ | |
| 41 | public function buildLinearTree(array $categories, int $parentId = 0, int $indent = 0): array | |
| 42 | { | |
| 43 | return $this->treeBuilder->buildLinearTree($categories, $parentId, $indent); | |
| 44 | } | |
| 45 | ||
| 46 | /** | |
| 47 | * Builds the admin category tree. | |
| 48 | * | |
| 49 | * @param array<int, array<string, mixed>> $categories | |
| 50 | * @return array<int, array<array-key, mixed>> | |
| 51 | */ | |
| 52 | public function buildAdminCategoryTree(array $categories, int $parentId = 0): array | |
| 53 | { | |
| 54 | return $this->treeBuilder->buildAdminCategoryTree($categories, $parentId); | |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * Gets direct children of a category. | |
| 59 | * | |
| 60 | * @param array<int, array<int, array<string, mixed>>> $childrenMap | |
| 61 | * @return array<int> | |
| 62 | */ | |
| 63 | public function getChildren(array $childrenMap, int $categoryId): array | |
| 64 | { | |
| 65 | return $this->treeBuilder->getChildren($childrenMap, $categoryId); | |
| 66 | } | |
| 67 | ||
| 68 | /** | |
| 69 | * Gets all descendant nodes of a category. | |
| 70 | * | |
| 71 | * @param array<int, array<int, array<string, mixed>>> $childrenMap | |
| 72 | * @return array<int> | |
| 73 | */ | |
| 74 | public function getChildNodes(array $childrenMap, int $categoryId): array | |
| 75 | { | |
| 76 | return $this->treeBuilder->getChildNodes($childrenMap, $categoryId); | |
| 77 | } | |
| 78 | ||
| 79 | /** | |
| 80 | * Computes the depth level of a category. | |
| 81 | * | |
| 82 | * @param array<int, array<string, mixed>> $categoryNames | |
| 83 | */ | |
| 84 | public function getLevelOf(array $categoryNames, int $categoryId): int | |
| 85 | { | |
| 86 | return $this->treeBuilder->computeLevel($categoryNames, $categoryId); | |
| 87 | } | |
| 88 | ||
| 89 | /** | |
| 90 | * Gets the path from root to a category. | |
| 91 | * | |
| 92 | * @param array<int, array<string, mixed>> $categoryNames | |
| 93 | * @return array<int> | |
| 94 | */ | |
| 95 | public function getNodes(array $categoryNames, int $categoryId): array | |
| 96 | { | |
| 97 | return $this->treeBuilder->getNodes($categoryNames, $categoryId); | |
| 98 | } | |
| 99 | } |