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

Method isValidParent

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

Source from the content-addressed store, hash-verified

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

Callers 3

createMethod · 0.95
updateMethod · 0.95
updateGroupMethod · 0.95

Calls 1

readOwnMethod · 0.45

Tested by

no test coverage detected