| Conditions | 6 |
| Paths | 9 |
| Total Lines | 23 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 6.0208 |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 26 | /** |
||
| 27 | * Transforms a menu item. Add the restricted property to a menu item |
||
| 28 | * when situable. |
||
| 29 | * |
||
| 30 | * @param array $item A menu item |
||
| 31 | * @return array The transformed menu item |
||
| 32 | */ |
||
| 33 | 44 | public function transform($item) |
|
| 34 | { |
||
| 35 | // Set a special attribute when item is not allowed. Items with this |
||
| 36 | // attribute will be filtered out of the menu. |
||
| 37 | |||
| 38 | 44 | if (! $this->isAllowed($item)) { |
|
| 39 | 4 | $item['restricted'] = true; |
|
| 40 | } |
||
| 41 | |||
| 42 | 44 | return $item; |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Check if a menu item is allowed for the current user. |
||
| 47 | * |
||
| 48 | * @param array $item A menu item |
||
| 49 | * @return bool |
||
| 72 |