Calculates and returns the depth of a section reference

@param string $reference

@return int
174963
public static function calcDepth($reference)
    {
        $reference = self::trimReference($reference);
        $reference = self::normalizeReference($reference);
        return substr_count($reference, '.');
    }
989287
public function getRawReference($reference)
    {

        $reference = $this->mapReference($reference);

        if (!array_key_exists($reference, $this->container)) {
            throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $reference));
        }

        return $this->container[$reference];
    }
220792
public function hasReference( $reference, &$referenceDetail = null )
    {

        $referenceDetail = null;

        foreach( $this->__get('references') as $name => $detail ) {

            if( $name == $reference or $detail[0] == $reference ) {
                $referenceDetail = $detail;
                return $name;
            }

        }

        return null;

    }
412557
private function parseRefAsTag($reference): ?string
    {
        if (preg_match(self::REGEX_TAG, $reference, $matches) !== 1) {
            return null;
        }

        return $matches[1];
    }
996606
public function getSection($reference)
    {
        $reference = Section::trimReference($reference);
        $reference = strtolower(Section::normalizeReference($reference));

        foreach ($this->sections as $sectionKey => $section) {
            $potentialMatch = strtolower(Section::normalizeReference($sectionKey));
            if ($reference === $potentialMatch) {
                return $section;
            }
        }

        throw new UnexpectedValueException('Section with a reference of ' . $reference . ' cannot be found!');
    }
1369696
public function getNode($ref): ?Node
    {
        $nodeRef = $this->toNodeRef($ref);
        if (!$nodeRef instanceof NodeRef) {
            return null;
        }

        try {
            return $this->ncrCache->getNode($nodeRef);
        } catch (NodeNotFound $e) {
            return null;
        } catch (\Throwable $e) {
            if ($this->debug) {
                throw $e;
            }

            $this->logger->error(
                sprintf(
                    '%s::Unable to process twig "ncr_get_node" function for [{node_ref}].',
                    ClassUtils::getShortName($e)
                ),
                ['exception' => $e, 'node_ref' => (string)$nodeRef]
            );
        }

        return null;
    }
1117442
public function setReference($reference)
    {
        if (!empty($reference) && ctype_print($reference)) {
            $this->reference = trim($reference);
        }

        return $this;
    }
1045974
public function limit($var, $depth, array &$references = [])
    {
        if ($depth > $this->depthLimit) {
            return '*DEPTH LIMIT*';
        }

        if (is_array($var)) {
            return $this->limitArray($var, $depth, $references);
        }

        if (is_object($var)) {
            return $this->limitObject($var, $depth, $references);
        }

        return $var;
    }
117625
public static function ref($ref)
    {
        if (isset($ref['$id'])) {
            if ($ref['$ref'] == self::collectionName()) {
                return self::id($ref['$id']);
            }
        }

        return null;
    }
614202
private function get_target_section() {

        if (!$this->fixeddataset) {
            $key = rand(1, self::$paramsections[$this->size]);
        } else {
            // Using section 1.
            $key = 1;
        }

        return $key;
    }
97855
public function resolve($reference)
    {
        if (empty($reference)) {
            return $reference;
        }

        if ($this->isResolvableAnonymousReference($reference)) {
            return $this->resolveAnonymousReference($reference);
        }

        return $this->resolveInternal($reference);
    }
900150
protected function renderReference($reference)
    {
        if (!isset($this->settings['references'][$reference])) {
            $this->outputLine('Reference "%s" is not configured', [$reference]);
            $this->quit(1);
        }
        $referenceConfiguration = $this->settings['references'][$reference];
        $affectedClassNames = $this->getAffectedClassNames($referenceConfiguration['affectedClasses']);
        $parserClassName = $referenceConfiguration['parser']['implementationClassName'];
        $parserOptions = isset($referenceConfiguration['parser']['options']) ? $referenceConfiguration['parser']['options'] : [];
        /** @var $classParser \Neos\DocTools\Domain\Service\AbstractClassParser */
        $classParser = new $parserClassName($parserOptions);
        $classReferences = [];
        foreach ($affectedClassNames as $className) {
            $classReferences[$className] = $classParser->parse($className);
        }
        usort($classReferences, function (ClassReference $a, ClassReference $b) {
            if ($a->getTitle() == $b->getTitle()) {
                return 0;
            }

            return ($a->getTitle() < $b->getTitle()) ? -1 : 1;
        });
        $standaloneView = new \Neos\FluidAdaptor\View\StandaloneView();
        $templatePathAndFilename = isset($referenceConfiguration['templatePathAndFilename']) ? $referenceConfiguration['templatePathAndFilename'] : 'resource://Neos.DocTools/Private/Templates/ClassReferenceTemplate.txt';
        $standaloneView->setTemplatePathAndFilename($templatePathAndFilename);
        $standaloneView->assign('title', isset($referenceConfiguration['title']) ? $referenceConfiguration['title'] : $reference);
        $standaloneView->assign('classReferences', $classReferences);
        file_put_contents($referenceConfiguration['savePathAndFilename'], $standaloneView->render());
        $this->outputLine('DONE.');
    }
1077602
private function loadExternalRef($reference)
    {
        list($prefix, $path) = parse_external_ref($reference);
        return $this->loaderManager->getLoader($prefix)->load($path);
    }
1367500
protected function calculateNodeDepthFromRelativeLevel($relativeLevel, NodeInterface $referenceNode)
    {
        if ($relativeLevel > 0) {
            $depth = $relativeLevel;
        } else {
            $currentSiteDepth = $this->getNodeLevelInSite($referenceNode);
            if ($currentSiteDepth + $relativeLevel < 1) {
                $depth = 1;
            } else {
                $depth = $currentSiteDepth + $relativeLevel + 1;
            }
        }

        return $depth;
    }
589379
public function getInvoiceByReference(string $reference)
    {
        $invoiceRow = $this->_createInvoiceQuery()
            ->where(['reference' => $reference])
            ->one();

        if ($invoiceRow) {
            return new Invoice($invoiceRow);
        }

        return null;
    }
1040378
public function getRef()
    {
        if (is_null($this->ref)) {
            $tags = $this->tags;
            sort($tags);
            $this->ref = md5(implode('-', $tags));
        }
        return $this->ref;
    }
250850
public function get_reference_details($reference, $filestatus = 0) {
        if ($this->has_moodle_files()) {
            $fileinfo = null;
            $params = file_storage::unpack_reference($reference, true);
            if (is_array($params)) {
                $context = context::instance_by_id($params['contextid'], IGNORE_MISSING);
                if ($context) {
                    $browser = get_file_browser();
                    $fileinfo = $browser->get_file_info($context, $params['component'], $params['filearea'], $params['itemid'], $params['filepath'], $params['filename']);
                }
            }
            if (empty($fileinfo)) {
                if ($filestatus == 666) {
                    if (is_siteadmin() || ($context && has_capability('moodle/course:managefiles', $context))) {
                        return get_string('lostsource', 'repository',
                                $params['contextid']. '/'. $params['component']. '/'. $params['filearea']. '/'. $params['itemid']. $params['filepath']. $params['filename']);
                    } else {
                        return get_string('lostsource', 'repository', '');
                    }
                }
                return get_string('undisclosedsource', 'repository');
            } else {
                return $fileinfo->get_readable_fullname();
            }
        }
        return '';
    }