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

Method isValidParent

lib/Service/PanoramaService.php:271–293  ·  view source on GitHub ↗
(int $parentId, ?int $itemId = null)

Source from the content-addressed store, hash-verified

269 }
270
271 private function isValidParent(int $parentId, ?int $itemId = null): bool {
272 if ($parentId === 0) {
273 return true;
274 }
275 if ($itemId !== null && $parentId === $itemId) {
276 return false;
277 }
278
279 $visited = [];
280 $currentId = $parentId;
281 while ($currentId !== 0) {
282 if (isset($visited[$currentId]) || ($itemId !== null && $currentId === $itemId)) {
283 return false;
284 }
285 $visited[$currentId] = true;
286 $parent = $this->PanoramaMapper->readOwn($currentId);
287 if (empty($parent) || (int)$parent['type'] !== self::REPORT_TYPE_GROUP) {
288 return false;
289 }
290 $currentId = (int)$parent['parent'];
291 }
292 return true;
293 }
294
295 private function normalizePages(mixed $pages): ?array {
296 if (is_string($pages)) {

Callers 4

createMethod · 0.95
updateMethod · 0.95
createGroupMethod · 0.95
updateGroupMethod · 0.95

Calls 1

readOwnMethod · 0.45

Tested by

no test coverage detected