Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LinkStub.php

function LinkStub::__construct

Overrides ConstStub::__construct

File

vendor/symfony/var-dumper/Caster/LinkStub.php, line 26

Class

LinkStub
Represents a file or a URL.

Namespace

Symfony\Component\VarDumper\Caster

Code

public function __construct(string $label, int $line = 0, ?string $href = null) {
    $this->value = $label;
    if (!\is_string($href ??= $label)) {
        return;
    }
    if (str_starts_with($href, 'file://')) {
        if ($href === $label) {
            $label = substr($label, 7);
        }
        $href = substr($href, 7);
    }
    elseif (str_contains($href, '://')) {
        $this->attr['href'] = $href;
        return;
    }
    if (!is_file($href)) {
        return;
    }
    if ($line) {
        $this->attr['line'] = $line;
    }
    if ($label !== ($this->attr['file'] = realpath($href) ?: $href)) {
        return;
    }
    if ($composerRoot = $this->getComposerRoot($href, $this->inVendor)) {
        $this->attr['ellipsis'] = \strlen($href) - \strlen($composerRoot) + 1;
        $this->attr['ellipsis-type'] = 'path';
        $this->attr['ellipsis-tail'] = 1 + ($this->inVendor ? 2 + \strlen(implode('', \array_slice(explode(\DIRECTORY_SEPARATOR, substr($href, 1 - $this->attr['ellipsis'])), 0, 2))) : 0);
    }
    elseif (3 < \count($ellipsis = explode(\DIRECTORY_SEPARATOR, $href))) {
        $this->attr['ellipsis'] = 2 + \strlen(implode('', \array_slice($ellipsis, -2)));
        $this->attr['ellipsis-type'] = 'path';
        $this->attr['ellipsis-tail'] = 1;
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal