LdapTools\Ldif\LdifParser::getKeyAndValue PHP Метод

getKeyAndValue() защищенный Метод

protected getKeyAndValue ( string $line ) : array
$line string
Результат array
    protected function getKeyAndValue($line)
    {
        $position = strpos($line, Ldif::KEY_VALUE_SEPARATOR);
        // There must be a key/value separator ':' present in the line, and it cannot be the first value
        if ($position === false || $position === 0) {
            $this->throwException('Expecting a LDIF directive');
        }
        // This accounts for double '::' base64 format.
        $key = rtrim(substr($line, 0, $position), ':');
        // Base64 encoded format...
        if ($this->startsWith(Ldif::KEY_VALUE_SEPARATOR, substr($line, $position + 1))) {
            $value = base64_decode($this->getContinuedValues(ltrim(substr($line, $position + 2), ' ')));
            // The value needs to be retrieved from a URL...
        } elseif ($this->startsWith(Ldif::URL, substr($line, $position + 1))) {
            // Start the position after the URL indicator and remove any spaces.
            $value = $this->getValueFromUrl($this->getContinuedValues(ltrim(substr($line, $position + 2), ' ')));
            // Just a typical value format...
        } else {
            // A space at the start of the value should be ignored. A value beginning with a space should be base64 encoded.
            $value = $this->getContinuedValues(ltrim(substr($line, $position + 1), " "));
        }
        return [$key, $value];
    }