/** * Parse the given tokens into a data structure * * @param array $data * @param array $tokens * @return void */ protected function _parseLdapSchemaSyntax(array &$data, array $tokens) { // tokens that have no value associated $noValue = array('single-value', 'obsolete', 'collective', 'no-user-modification', 'abstract', 'structural', 'auxiliary'); // tokens that can have multiple values $multiValue = array('must', 'may', 'sup'); while (count($tokens) > 0) { $token = strtolower(array_shift($tokens)); if (in_array($token, $noValue)) { $data[$token] = true; // single value token } else { $data[$token] = array_shift($tokens); // this one follows a string or a list if it is multivalued if ($data[$token] == '(') { // this creates the list of values and cycles through the tokens // until the end of the list is reached ')' $data[$token] = array(); while ($tmp = array_shift($tokens)) { if ($tmp == ')') { break; } if ($tmp != '$') { $data[$token][] = Ldap\Attribute::convertFromLdapValue($tmp); } } } else { $data[$token] = Ldap\Attribute::convertFromLdapValue($data[$token]); } // create a array if the value should be multivalued but was not if (in_array($token, $multiValue) && !is_array($data[$token])) { $data[$token] = array($data[$token]); } } } }