LdapTools\Ldif\LdifParser::getLdapControl PHP Method

getLdapControl() protected method

Validate a control directive and get the value for the control and the criticality.
protected getLdapControl ( string $value ) : LdapControl
$value string
return LdapTools\Connection\LdapControl
    protected function getLdapControl($value)
    {
        $values = explode(' ', $value);
        // This should never happen, but it seems better to cover it in case...
        if (empty($values) || $values === false) {
            $this->throwException(sprintf('Expecting a LDAP control but got "%s"', $value));
        }
        // The first value should be an actual OID...
        if (!preg_match(LdapUtilities::MATCH_OID, $values[0])) {
            $this->throwException(sprintf('The control directive has an invalid OID format "%s"', $values[0]));
        }
        $control = new LdapControl($values[0]);
        if (isset($values[1])) {
            $control->setCriticality($this->getBoolFromStringBool($values[1]));
        }
        if (isset($values[2])) {
            $control->setValue($values[2]);
        }
        return $control;
    }