(int $parentId, ?int $itemId = null)
| 594 | } |
| 595 | |
| 596 | private function isValidParent(int $parentId, ?int $itemId = null): bool { |
| 597 | if ($parentId === 0) { |
| 598 | return true; |
| 599 | } |
| 600 | if ($itemId !== null && $parentId === $itemId) { |
| 601 | return false; |
| 602 | } |
| 603 | |
| 604 | $visited = []; |
| 605 | $currentId = $parentId; |
| 606 | while ($currentId !== 0) { |
| 607 | if (isset($visited[$currentId]) || ($itemId !== null && $currentId === $itemId)) { |
| 608 | return false; |
| 609 | } |
| 610 | $visited[$currentId] = true; |
| 611 | $parent = $this->ReportMapper->readOwn($currentId); |
| 612 | if (empty($parent) || (int)$parent['type'] !== self::REPORT_TYPE_GROUP) { |
| 613 | return false; |
| 614 | } |
| 615 | $currentId = (int)$parent['parent']; |
| 616 | } |
| 617 | return true; |
| 618 | } |
| 619 | |
| 620 | /** |
| 621 | * rename report |
no test coverage detected