(int $parentId, ?int $itemId = null)
| 707 | } |
| 708 | |
| 709 | private function isValidParent(int $parentId, ?int $itemId = null): bool { |
| 710 | if ($parentId === 0) { |
| 711 | return true; |
| 712 | } |
| 713 | if ($itemId !== null && $parentId === $itemId) { |
| 714 | return false; |
| 715 | } |
| 716 | |
| 717 | $visited = []; |
| 718 | $currentId = $parentId; |
| 719 | while ($currentId !== 0) { |
| 720 | if (isset($visited[$currentId]) || ($itemId !== null && $currentId === $itemId)) { |
| 721 | return false; |
| 722 | } |
| 723 | $visited[$currentId] = true; |
| 724 | $parent = $this->ReportMapper->readOwn($currentId); |
| 725 | if (empty($parent) || (int)$parent['type'] !== self::REPORT_TYPE_GROUP) { |
| 726 | return false; |
| 727 | } |
| 728 | $currentId = (int)$parent['parent']; |
| 729 | } |
| 730 | return true; |
| 731 | } |
| 732 | |
| 733 | /** |
| 734 | * rename report |
no test coverage detected