MCPcopy Create free account
hub / github.com/Rello/analytics / isValidParent

Method isValidParent

lib/Service/ReportService.php:705–727  ·  view source on GitHub ↗
(int $parentId, ?int $itemId = null)

Source from the content-addressed store, hash-verified

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

Callers 3

createMethod · 0.95
updateMethod · 0.95
updateGroupMethod · 0.95

Calls 1

readOwnMethod · 0.45

Tested by

no test coverage detected