Parses a string containing LDIF data and returns an object with the entries it contains.

@param string $ldif
@return Ldif
@throws LdifParserException
519883
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;
    }
843557
public function read_entries($dn, $filter, $attributes = null)
    {
        $this->_debug("C: Read $dn [{$filter}]");

        if ($this->conn && $dn) {
            $result = @ldap_read($this->conn, $dn, $filter, $attributes, 0, (int)$this->config['sizelimit'], (int)$this->config['timelimit']);
            if ($result === false) {
                $this->_error("ldap_read() failed with " . ldap_error($this->conn));
                return false;
            }

            $this->_debug("S: OK");
            return ldap_get_entries($this->conn, $result);
        }

        return false;
    }
118414
public function read($dn)
	{
		$base = substr($dn, strpos($dn, ',') + 1);
		$cn = substr($dn, 0, strpos($dn, ','));
		$result = @ldap_read($this->resource, $base, $cn);

		if ($result)
		{
			return @ldap_get_entries($this->resource, $result);
		}
		else
		{
			return $result;
		}
	}
1239060
public static function parse( $string, $charsetIn = NULL, $charsetOut = NULL )
	{
		$vcard	= new ADT_VCard;
		return self::parseInto( $string, $vcard, $charsetIn, $charsetOut );
	}
1232448
public function parse($string)
    {
        $hashModes = [];

        foreach($this->hashLibrary as $hash){
            if(preg_match('/'.$hash['regex'].'/i', $string)) {
                foreach($hash['modes'] as $mode) {
                    $hashModes[] = new HashMode([
                        'name' => $mode['name'],
                        'hashcat' => $mode['hashcat'],
                        'john' => $mode['john'],
                        'extended' => $mode['extended'],
                    ]);
                }
            }
        }

        $this->modes = $hashModes;
        return $this;
    }
1138554
public function parse($sddl)
    {
        if (!preg_match(self::MATCH_SDDL, (string) $sddl, $matches)) {
            throw new SddlParserException('The SDDL string is not valid.');
        }

        $sd = (new SecurityDescriptor())
            ->setOwner($this->getSid($matches[1], 'owner'))
            ->setGroup($this->getSid($matches[2], 'group'));

        $this->parseAcl(strtoupper($matches[4]), $matches[5], $sd);
        if (isset($matches[7])) {
            $this->parseAcl(strtoupper($matches[7]), $matches[8], $sd);
        }

        return $sd;
    }
172719
protected function addControlsToString($ldif)
    {
        foreach ($this->controls as $control) {
            $value = $control->getOid().' '.$control->getCriticality();
            if (!is_null($control->getValue())) {
                $value .= ' '.$control->getValue();
            }
            $ldif .= $this->getLdifLine(Ldif::DIRECTIVE_CONTROL, $value);
        }

        return $ldif;
    }
231624
protected function parseRoles($force = false)
    {
        if (null == $this->roles || $force) {
            $user = UserManager::instance()->getuser();
            $userRoles = $user ? $user->getRoles() : ['ROLE_ANONYMOUS'];
            $roleHierarchy = Base::instance()->get('SECURITY.role_hierarchy') ?: [];
            $roles = [];

            foreach ($userRoles as $role) {
                $roles = array_merge(
                    $roles,
                    [$role],
                    $this->getHierarchy($role, $roleHierarchy)
                );
            }

            $this->roles = array_unique($roles);
        }
    }
321551
protected function parse($data, $eof) {
        if (!xml_parse($this->xml_parser, $data, $eof)) {
            throw new progressive_parser_exception(
                'xml_parsing_error', null,
                sprintf('XML error: %s at line %d, column %d',
                        xml_error_string(xml_get_error_code($this->xml_parser)),
                        xml_get_current_line_number($this->xml_parser),
                        xml_get_current_column_number($this->xml_parser)));
        }
    }
299062
public function parseString($input, $config = NULL, $encoding = NULL, $input, $config = NULL, $encoding = NULL)
    {
    }
425253
protected function _objectToRDF($item) {
    $object = new stdClass();

    if(self::_isValue($item)) {
      $object->type = 'literal';
      $value = $item->{'@value'};
      $datatype = property_exists($item, '@type') ? $item->{'@type'} : null;

      // convert to XSD datatypes as appropriate
      if(is_bool($value)) {
        $object->value = ($value ? 'true' : 'false');
        $object->datatype = $datatype ? $datatype : self::XSD_BOOLEAN;
      } else if(is_double($value) || $datatype == self::XSD_DOUBLE) {
        // canonical double representation
        $object->value = preg_replace(
          '/(\d)0*E\+?/', '$1E', sprintf('%1.15E', $value));
        $object->datatype = $datatype ? $datatype : self::XSD_DOUBLE;
      } else if(is_integer($value)) {
        $object->value = strval($value);
        $object->datatype = $datatype ? $datatype : self::XSD_INTEGER;
      } else if(property_exists($item, '@language')) {
        $object->value = $value;
        $object->datatype = $datatype ? $datatype : self::RDF_LANGSTRING;
        $object->language = $item->{'@language'};
      } else {
        $object->value = $value;
        $object->datatype = $datatype ? $datatype : self::XSD_STRING;
      }
    } else {
      // convert string/node object to RDF
      $id = is_object($item) ? $item->{'@id'} : $item;
      $object->type = (strpos($id, '_:') === 0) ? 'blank node' : 'IRI';
      $object->value = $id;
    }

    // skip relative IRIs
    if($object->type === 'IRI' && !self::_isAbsoluteIri($object->value)) {
      return null;
    }

    return $object;
  }
313604
public function parse($input, $file = null)
    {
        $this->languageSpecifierLine = null;
        $this->input = $input;
        $this->file = $file;
        $this->tags = array();

        try {
            $this->lexer->analyse($this->input, 'en');
        } catch (LexerException $e) {
            throw new ParserException(
                sprintf('Lexer exception "%s" thrown for file %s', $e->getMessage(), $file),
                0,
                $e
            );
        }

        $feature = null;
        while ('EOS' !== ($predicted = $this->predictTokenType())) {
            $node = $this->parseExpression();

            if (null === $node || "\n" === $node) {
                continue;
            }

            if (!$feature && $node instanceof FeatureNode) {
                $feature = $node;
                continue;
            }

            if ($feature && $node instanceof FeatureNode) {
                throw new ParserException(sprintf(
                    'Only one feature is allowed per feature file. But %s got multiple.',
                    $this->file
                ));
            }

            if (is_string($node)) {
                throw new ParserException(sprintf(
                    'Expected Feature, but got text: "%s"%s',
                    $node,
                    $this->file ? ' in file: ' . $this->file : ''
                ));
            }

            if (!$node instanceof FeatureNode) {
                throw new ParserException(sprintf(
                    'Expected Feature, but got %s on line: %d%s',
                    $node->getKeyword(),
                    $node->getLine(),
                    $this->file ? ' in file: ' . $this->file : ''
                ));
            }
        }

        return $feature;
    }
313520
protected function parseListEntry( $entry )
	{
		$data	= array();
		$parts	= preg_split("/[\s]+/", $entry, 9 );
		if( $parts[0] == "total" )
			return array();
		$data['isdir']			= $parts[0]{0} === "d";
		$data['islink']			= $parts[0]{0} === "l";
		$data['isfile']			= $parts[0]{0} === "-";
		$data['permissions']	= $parts[0];
		$data['number']			= $parts[1];
		$data['owner']			= $parts[2];
		$data['group']			= $parts[3];
		$data['size']			= $parts[4];
		$data['month']			= $parts[5];
		$data['day']			= $parts[6];
		$data['time']			= $parts[7];
		$data['name']			= $parts[8];
		if( preg_match( "/:/", $data['time'] ) )
			$data['year']		= date( "Y" );
		else
		{
			$data['year']		= $data['time'];
			$data['time']		= "00:00";
		}
		$data['timestamp']		= strtotime( $data['day']." ".$data['month']." ".$data['year']." ".$data['time'] );
		$data['datetime']		= date( "c", $data['timestamp'] );
		$data['type']			= $this->fileTypes[$parts[0]{0}];
		$data['type_short']		= $data['type']{0};
		$data['octal']			= $this->getPermissionsAsOctal( $parts[0] );
		$data['raw']			= $entry;
		return $data;
	}
1086857
public function parse( $data = null, $type = null, $delimiter = null ) {

		if ( ! empty( $data ) ) {
			$this->input = $data;
		}

		if ( ! empty( $type ) && in_array( $type, $this->types, true ) ) {
			$this->type = $type;
		}

		if ( !empty( $delimiter ) )
			$this->delimiter = $delimiter;

		if ( method_exists( $this, "parse_{$this->type}" ) ) {
			return call_user_func( array( $this, 'parse_' . $this->type ) );
		}

		return $this->parsed;
	}
623966
public function parseFile($file)
    {
        $str = @\file_get_contents($file);
        if (false === $str) {
            throw new Exception('Can\'t read file.');
        }

        return $this->parse($str);
    }
973258
public function parse($input)
    {
        $this->inValuePath = false;
        $this->lexer->setInput($input);
        $this->lexer->moveNext();

        $node = null;
        if ($this->mode->equals(Mode::FILTER)) {
            $node = $this->disjunction();
        } else {
            $node = $this->path();
        }

        $this->match(null);

        return $node;
    }
337621
protected static function parseDefinition($definition)
    {
        if (!is_array($definition)) {
            $definition = deserialize($definition, true);

            return $definition;
        }

        return $definition;
    }