Serialize or deserialize the scheme.

@param array $scheme

@return array
346227
protected static function toggleSerializeScheme(array $scheme)
    {
        foreach ($scheme as $name => &$options) {
            if (is_array($options)) {
                foreach (ParasiticAgent::methods() as $method) {
                    self::toggleSerializeClosure($options, $method);
                }
            }
        }

        return $scheme;
    }
1109564
private function set_scheme($scheme)
    {
        if ($scheme === null)
        {
            $this->scheme = null;
        }
        elseif (!preg_match('/^[A-Za-z][0-9A-Za-z+\-.]*$/', $scheme))
        {
            $this->scheme = null;
            return false;
        }
        else
        {
            $this->scheme = strtolower($scheme);
        }
        return true;
    }
1069598
private function filterScheme(string $scheme): string
    {
        $result = strtolower($scheme);
        if (isset(self::$knownPorts[$result])) {
            return $result;
        }

        $result = preg_replace('#:(//)?$#', '', $result);
        if (!preg_match('#^[a-z][a-z0-9\+\-\.]*$#i', $result)) {
            throw new \InvalidArgumentException(sprintf('Invalid scheme "%s".', $scheme));
        }

        return $result;
    }
1121762
protected function validateScheme($scheme)
    {
        if (!$scheme) {
            throw new InvalidArgumentException('No scheme specified');
        }
        if (!in_array($scheme, self::$schemes)) {
            throw new InvalidArgumentException(
                'Unknown socket scheme: ' . $scheme
            );
        }

        if ($scheme == self::SCHEME_WEBSOCKET_SECURE) {
            return self::SCHEME_UNDERLYING_SECURE;
        }
        return self::SCHEME_UNDERLYING;
    }
965895
public function serialize($entity)
    {
        return array($this->getName().'.'.$this->_target_parent_key => $entity->get($this->_target_parent_key));
    }
968938
public function serialize(): string
    {
        return serialize(
            $this->definitionMap
                ->mapWithKeys(function (DefinitionNode $node, string $key): array {
                    return [$key => AST::toArray($node)];
                })
        );
    }
671046
public function filterScheme($scheme)
    {
        $valids = [
            ''      => true,
            'http'  => true,
            'https' => true,
        ];
        $scheme = str_replace('://', '', strtolower((string) $scheme));
        if (!isset($valids[$scheme])) {
            throw new \InvalidArgumentException('Uri scheme must be one of: "", "https", "http"');
        }

        return $scheme;
    }
467947
public function serialize($entity)
    {
        return array($this->getName().'.'.$this->_parent_key => $entity->get($this->_parent_key));
    }
160066
protected function serializeParams(array $params)
    {
        $serialized = array();
        foreach ($params as $param) {
            $serialized[] = $this->serializer->serialize($param);
        }

        return $serialized;
    }
832168
public function setSchemes($schemes)
    {
        $this->schemes = array_map('strtolower', (array) $schemes);
        $this->compiled = null;

        return $this;
    }
246310
private function deserializeArrayRecursively(array $array): array
    {
        $data = [];
        foreach ($array as $key => $value) {
            $data[$key] = $this->deserializeValue($value);
        }

        return $data;
    }
720049
public function validateScheme($scheme = null)
    {
        if ($scheme === null) {
            $parsed = parse_url($this->uri);
            $scheme = isset($parsed['host']) ? $parsed['host'] : $parsed['path'];
        }
        return in_array($scheme, $this->schemes);
    }
688064
public function jsonSerialize(): array
    {
        $outObj         = array();
        $outObj['name'] = $this->name;
        if ($this->type !== null) {
            $outObj['type'] = $this->type;
        }
        if ($this->dynamic !== null) {
            $outObj['dynamic'] = $this->dynamic;
        }
        if ($this->docs !== null) {
            $outObj['docs'] = $this->docs;
        }
        return $outObj;
    }
97130
final protected function filter(array &$data, array $scheme = [])
    {
        if (empty($scheme)) {
            $scheme = $this->scheme;
        }

        if (empty($scheme['filter'])) {
            return $data;
        }

        $filter = [];

        foreach ($scheme['filter'] as $f => $r) {
            $filter[$f] = $r;
        }

        if (empty($filter)) {
            return $data;
        }

        $result = filter_var_array($data, $filter);

        if (empty($result)) {
            return $data;
        }

        foreach ($result as $key => $value) {
            $data[$key] = $value;
        }

        return $data;
    }
482669
private function filterScheme($scheme)
    {
        $scheme = \strtolower($scheme);
        $scheme = \preg_replace('#:(//)?$#', '', $scheme);

        if ('' === $scheme) {
            return '';
        }

        if (!isset(static::$schemes[$scheme])) {
            throw new \InvalidArgumentException(sprintf(
                'Unsupported scheme "%s"; must be any empty string or in the set (%s)',
                $scheme,
                \implode(', ', \array_keys(static::$schemes))
            ));
        }

        return $scheme;
    }
876686
protected function nUrlScheme($scheme)
    {
        if (!($scheme = (string) $scheme)) {
            return $scheme; // Nothing to do.
        }
        if (mb_strpos($scheme, ':') !== false) {
            $scheme = strstr($scheme, ':', true);
        }
        return mb_strtolower($scheme);
    }
452087
public function withScheme($scheme): UriInterface
    {
        $scheme = $this->filterScheme($scheme);

        $clone = clone $this;
        $clone->scheme = $scheme;

        return $clone;
    }