Total Complexity | 5 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | trait WithCategories |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * Get all categories |
||
24 | * |
||
25 | * @return Category[] |
||
26 | */ |
||
27 | 10 | public function getCategories() : array { |
|
28 | 10 | return $this->container->getHierarchyLevel(Category::class); |
|
29 | } |
||
30 | |||
31 | /** |
||
32 | * Get categories container query |
||
33 | * |
||
34 | * @return ContainerQuery |
||
35 | */ |
||
36 | 3 | public function queryCategories() : ContainerQuery { |
|
38 | } |
||
39 | |||
40 | |||
41 | /** |
||
42 | * Add one or more category to object |
||
43 | * |
||
44 | * @param Category ...$categories Category objects |
||
45 | * |
||
46 | * @return $this |
||
47 | */ |
||
48 | 1 | public function addCategory(Category ...$categories) : WithCategoriesInterface { |
|
49 | 1 | foreach ($categories as $category) { |
|
50 | 1 | $this->insertIntoContainer($category); |
|
51 | } |
||
52 | 1 | return $this; |
|
53 | } |
||
54 | |||
55 | /** |
||
56 | * Creates a new category and adds it to the object |
||
57 | * |
||
58 | * @param string $name New category name |
||
59 | * @param string|int|null $id Id of the new category - if omitted -> it is generated automatically as unique string |
||
60 | * |
||
61 | * @return Category New category |
||
62 | */ |
||
63 | 10 | public function category(string $name = '', $id = null) : Category { |
|
67 | } |
||
68 | |||
69 | } |