Returns normalized url.

@param PageUrlAnnotation $annotation The page url annotation.

@return array
777029
public function normalize(PageUrlAnnotation $annotation)
	{
		$parser = new Parser($this->baseUrl);
		$parser->merge(new Parser($annotation->url));

		$parser->setParams(array_merge($parser->getParams(), $annotation->params));

		$ret = $parser->getComponents();

		if ( $annotation->secure !== null && !empty($ret['scheme']) ) {
			$ret['scheme'] = $annotation->secure ? 'https' : 'http';
		}

		return $ret;
	}
624098
public function getNormalizedUrl() {
		$parts = parse_url( $this->url );

		$scheme = isset( $parts['scheme'] ) ? $parts['scheme'] : 'http';
		$port = isset( $parts['port'] ) ?
			$parts['port'] : ( $scheme === 'https' ? '443' : '80' );
		$host = isset( $parts['host'] ) ? strtolower( $parts['host'] ) : '';
		$path = isset( $parts['path'] ) ? $parts['path'] : '';

		if ( ( $scheme === 'https' && $port != '443' ) ||
			( $scheme === 'http' && $port != '80' )
		) {
			$host = "{$host}:{$port}";
		}
		return "{$scheme}://{$host}{$path}";
	}
354227
public function normalizeUrl($url)
    {
        $url = trim($url, '/') .'/';

        // if the page is the index page then hide it from the menu
        if (strpos(strtolower($url), '/index.md/')) {
            $url = substr($url, 0, strpos($url, "index.md/"));
        }

        return $url;
    }
825118
private function readSourceMethod(Request $request, Annotation $annotation): string
    {
        $method = 'read' . $this->source($annotation);
        if (!method_exists($request, $method)) {
            throw new \RuntimeException(
                    'Unknown source ' . $annotation->getSource() . ' for '
                    . $annotation . ' on ' . get_class($request)
            );
        }

        return $method;
    }
401115
public function getArray($annotation, $default = []) {
        $str = $this->getString($annotation);
        if (is_array($str)) {
            return $str;
        }
        if ($str) {
            $str = trim($str);
            $str = pure_comman_string($str);

            return explode(',', $str);
        }

        return $default;
    }
493996
protected function extractSortInfo($sortAnnotation)
    {
        $sortInfo = ['direction' => null, 'column' => null];
        if ($sortAnnotation) {
            $direction = $sortAnnotation->direction;
            $sortInfo['direction'] = $direction;
            $column = $sortAnnotation->column;
            $sortInfo['column'] = $column;
        }

        return $sortInfo;
    }
1241978
public function normalizeLinkText($url)
    {
        if( property_exists($this,'normalizeLinkText') && is_callable($this->normalizeLinkText)){
            $fn = $this->normalizeLinkText;
            return $fn($url);
        }
        $parsed = $this->mdurl->parse($url, true);

        if ($parsed->hostname) {
            // Encode hostnames in urls like:
            // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
            //
            // We don't encode unknown schemas, because it's likely that we encode
            // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
            //
            $is = false;
            foreach (self::RECODE_HOSTNAME_FOR as &$v) {
                if( ($is = $v === $parsed->protocol) ) break;
            }
            if (empty($parsed->protocol) || $is) {
                try {
                    $parsed->hostname = $this->punycode->toUnicode($parsed->hostname);
                } catch (\Exception $e) { /**/ }
            }
        }
        return $this->mdurl->decode($this->mdurl->format($parsed));
    }
1251264
private function normalizeBinaryAnnotation(BinaryAnnotation $binaryAnnotation)
    {
        $normalizedAnnotation = [
            'key' => $binaryAnnotation->getKey(),
            'value' => (string) $binaryAnnotation->getValue(),
        ];

        if (null !== ($host = $binaryAnnotation->getHost())) {
            $normalizedAnnotation['endpoint'] = $this->normalizeEndpoint($host);
        }

        return $normalizedAnnotation;
    }
540548
public static function getAnnotationPoints($annotationClassName, $where = null)
    {
        if(null === $where)
        {
            return array_merge(
                static::$annotationRelation[$annotationClassName]['Class'] ?? [],
                static::$annotationRelation[$annotationClassName]['Method'] ?? [],
                static::$annotationRelation[$annotationClassName]['Property'] ?? []
            );
        }
        else
        {
            return static::$annotationRelation[$annotationClassName][$where] ?? [];
        }
    }
1358196
public function normalizeLink($url)
    {
        if( property_exists($this,'normalizeLink') && is_callable($this->normalizeLink)){
            $fn = $this->normalizeLink;
            return $fn($url);
        }
        $parsed = $this->mdurl->parse($url, true);

        if ($parsed->hostname) {
            // Encode hostnames in urls like:
            // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
            //
            // We don't encode unknown schemas, because it's likely that we encode
            // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
            //
            $is = false;
            foreach (self::RECODE_HOSTNAME_FOR as &$v) {
                if( ($is = $v === $parsed->protocol) ) break;
            }
            if (empty($parsed->protocol) || $is) {
                try {
                    $parsed->hostname = $this->punycode->toASCII($parsed->hostname);
                } catch (\Exception $e) { /**/ }
            }
        }

        return $this->mdurl->encode($this->mdurl->format($parsed));
    }
1009622
protected function _normalizedUrl($uri)
    {
        $out = $uri->getScheme() . '://';
        $out .= strtolower($uri->getHost());
        $out .= $uri->getPath();

        return $out;
    }
1355556
public function extend($annotation)
    {
        $params = get_object_vars($annotation);
        foreach ($params as $property => $value) {
            if (property_exists($this, $property) && !in_array($property, ['name', 'route'])) {
                if (!$this->$property) {
                    $this->$property = $value;
                }
            }
        }
    }
497074
public function getAnnotation($pageNumber, $annotationIndex)
    {

        $strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages/' . $pageNumber . '/annotations/' . $annotationIndex;
        $signedURI = Utils::sign($strURI);
        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
        $json = json_decode($responseStream);
        return $json->Annotation;
    }
1106403
public function validatePropertyAnnotation($annotation)
    {
        if (!in_array($annotation, $this->propertyAnnotations)) {
            throw $this->getException(
                'The property annotation isn\'t valid ("%s" given, expecting one of following: %s)',
                [$annotation, implode(', ', $this->propertyAnnotations)]
            );
        }

        return $annotation;
    }
1289026
private function parseDate(Annotation $annotation, string $field)
    {
        if ($annotation->hasValueByName($field)) {
            return new Date($annotation->getValueByName($field));
        }

        return null;
    }
460701
public static function fetchAnnotationsFromDocblock($annotation, $docblock)
    {
        if (preg_match_all(sprintf(self::$regex, $annotation), $docblock, $matched)) {
            return $matched[1];
        }
        return [];
    }
57132
protected function createLink(LinkAnnotation $annotation): Link
    {
        if (! preg_match(self::RESOURCE_PATTERN, $annotation->resource, $matches)) {
            throw new \LogicException(sprintf('Invalid resource definition: "%s"', $annotation->resource));
        }

        $link = new Link(
            $annotation->name,
            $matches['repository'],
            $matches['link']
        );

        $link->setParameters($annotation->parameters);
        $link->setMetadata($annotation->metadata);

        return $link;
    }