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

Method isValidParent

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

Source from the content-addressed store, hash-verified

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

Callers 3

createMethod · 0.95
updateMethod · 0.95
updateGroupMethod · 0.95

Calls 1

readOwnMethod · 0.45

Tested by

no test coverage detected