(int $parentId, ?int $itemId = null)
| 269 | } |
| 270 | |
| 271 | private function isValidParent(int $parentId, ?int $itemId = null): bool { |
| 272 | if ($parentId === 0) { |
| 273 | return true; |
| 274 | } |
| 275 | if ($itemId !== null && $parentId === $itemId) { |
| 276 | return false; |
| 277 | } |
| 278 | |
| 279 | $visited = []; |
| 280 | $currentId = $parentId; |
| 281 | while ($currentId !== 0) { |
| 282 | if (isset($visited[$currentId]) || ($itemId !== null && $currentId === $itemId)) { |
| 283 | return false; |
| 284 | } |
| 285 | $visited[$currentId] = true; |
| 286 | $parent = $this->PanoramaMapper->readOwn($currentId); |
| 287 | if (empty($parent) || (int)$parent['type'] !== self::REPORT_TYPE_GROUP) { |
| 288 | return false; |
| 289 | } |
| 290 | $currentId = (int)$parent['parent']; |
| 291 | } |
| 292 | return true; |
| 293 | } |
| 294 | |
| 295 | private function normalizePages(mixed $pages): ?array { |
| 296 | if (is_string($pages)) { |
no test coverage detected