src/LdapTools/Ldif/LdifParser.php
public function parse($ldif)
    {
        $ldifObject = new Ldif();

        $this->setup($ldif);
        while (!$this->isEndOfLdif()) {
            if ($this->isComment()) {
                $this->addCommentToQueueOrLdif($ldifObject);
                $this->nextLine();
            } elseif ($this->isStartOfEntry()) {
                $ldifObject->addEntry($this->parseEntry());
            } elseif ($this->startsWith(Ldif::DIRECTIVE_VERSION.Ldif::KEY_VALUE_SEPARATOR)) {
                $this->setLdifVersion($ldifObject, $this->getKeyAndValue($this->currentLine())[1]);
                $this->nextLine();
            } elseif ($this->isEndOfEntry()) {
                $this->nextLine();
            } else {
                $this->throwException('Unexpected line in LDIF');
            }
        }
        $this->cleanup();

        return $ldifObject;
    }
public function parse($ldif)
    {
        $ldifObject = new Ldif();

        $this->setup($ldif);
        while (!$this->isEndOfLdif()) {
            if ($this->isComment()) {
                $this->addCommentToQueueOrLdif($ldifObject);
                $this->nextLine();
            } elseif ($this->isStartOfEntry()) {
                $ldifObject->addEntry($this->parseEntry());
            } elseif ($this->startsWith(Ldif::DIRECTIVE_VERSION.Ldif::KEY_VALUE_SEPARATOR)) {
                $this->setLdifVersion($ldifObject, $this->getKeyAndValue($this->currentLine())[1]);
                $this->nextLine();
            } elseif ($this->isEndOfEntry()) {
                $this->nextLine();
            } else {
                $this->throwException('Unexpected line in LDIF');
            }
        }
        $this->cleanup();

        return $ldifObject;
    }
public function parse ( $ ldif ) { $ ldifObject = new Ldif ( ) ; $ this -> setup ( $ ldif ) ; while ( ! $ this -> isEndOfLdif ( ) ) { if ( $ this -> isComment ( ) ) { $ this -> addCommentToQueueOrLdif ( $ ldifObject ) ; $ this -> nextLine ( ) ; } elseif ( $ this -> isStartOfEntry ( ) ) { $ ldifObject -> addEntry ( $ this -> parseEntry ( ) ) ; } elseif ( $ this -> startsWith ( Ldif :: DIRECTIVE_VERSION . Ldif :: KEY_VALUE_SEPARATOR ) ) { $ this -> setLdifVersion ( $ ldifObject , $ this -> getKeyAndValue ( $ this -> currentLine ( ) ) [ 1 ] ) ; $ this -> nextLine ( ) ; } elseif ( $ this -> isEndOfEntry ( ) ) { $ this -> nextLine ( ) ; } else { $ this -> throwException ( 'Unexpected line in LDIF' ) ; } } $ this -> cleanup ( ) ; return $ ldifObject ; }
Parses a string containing LDIF data and returns an object with the entries it contains.

@param string $ldif
@return Ldif
@throws LdifParserException
Parses a string containing LDIF data and returns an object with the entries it contains .