id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
28,000
ldaptools/ldaptools
src/LdapTools/Query/Operator/BaseOperator.php
BaseOperator.getWasConverterUsed
public function getWasConverterUsed($alias = null) { if ($alias) { return isset($this->converterAliasUsed[$alias]) ? $this->converterAliasUsed[$alias] : false; } else { return $this->converterUsed; } }
php
public function getWasConverterUsed($alias = null) { if ($alias) { return isset($this->converterAliasUsed[$alias]) ? $this->converterAliasUsed[$alias] : false; } else { return $this->converterUsed; } }
[ "public", "function", "getWasConverterUsed", "(", "$", "alias", "=", "null", ")", "{", "if", "(", "$", "alias", ")", "{", "return", "isset", "(", "$", "this", "->", "converterAliasUsed", "[", "$", "alias", "]", ")", "?", "$", "this", "->", "converterAliasUsed", "[", "$", "alias", "]", ":", "false", ";", "}", "else", "{", "return", "$", "this", "->", "converterUsed", ";", "}", "}" ]
Get whether a converter was used or not. @param string|null $alias @return bool
[ "Get", "whether", "a", "converter", "was", "used", "or", "not", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L296-L303
28,001
ldaptools/ldaptools
src/LdapTools/Query/Operator/BaseOperator.php
BaseOperator.toLdapFilter
public function toLdapFilter($alias = null) { if ($this->skipFilterForAlias($alias)) { return ''; } if ($this->getValueForQuery($alias) instanceof BaseOperator) { return $this->getValueForQuery($alias)->toLdapFilter($alias); } return self::SEPARATOR_START .$this->getAttributeToQuery($alias) .$this->operatorSymbol .LdapUtilities::escapeValue($this->getValueForQuery($alias), null, LDAP_ESCAPE_FILTER) .self::SEPARATOR_END; }
php
public function toLdapFilter($alias = null) { if ($this->skipFilterForAlias($alias)) { return ''; } if ($this->getValueForQuery($alias) instanceof BaseOperator) { return $this->getValueForQuery($alias)->toLdapFilter($alias); } return self::SEPARATOR_START .$this->getAttributeToQuery($alias) .$this->operatorSymbol .LdapUtilities::escapeValue($this->getValueForQuery($alias), null, LDAP_ESCAPE_FILTER) .self::SEPARATOR_END; }
[ "public", "function", "toLdapFilter", "(", "$", "alias", "=", "null", ")", "{", "if", "(", "$", "this", "->", "skipFilterForAlias", "(", "$", "alias", ")", ")", "{", "return", "''", ";", "}", "if", "(", "$", "this", "->", "getValueForQuery", "(", "$", "alias", ")", "instanceof", "BaseOperator", ")", "{", "return", "$", "this", "->", "getValueForQuery", "(", "$", "alias", ")", "->", "toLdapFilter", "(", "$", "alias", ")", ";", "}", "return", "self", "::", "SEPARATOR_START", ".", "$", "this", "->", "getAttributeToQuery", "(", "$", "alias", ")", ".", "$", "this", "->", "operatorSymbol", ".", "LdapUtilities", "::", "escapeValue", "(", "$", "this", "->", "getValueForQuery", "(", "$", "alias", ")", ",", "null", ",", "LDAP_ESCAPE_FILTER", ")", ".", "self", "::", "SEPARATOR_END", ";", "}" ]
Returns the operator translated to its LDAP filter string value. @param string|null $alias @return string
[ "Returns", "the", "operator", "translated", "to", "its", "LDAP", "filter", "string", "value", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L311-L325
28,002
ldaptools/ldaptools
src/LdapTools/Query/Operator/BaseOperator.php
BaseOperator.getAttributeToQuery
protected function getAttributeToQuery($alias) { $attribute = $this->getTranslatedAttribute($alias) ?: $this->getAttribute(); // This avoids possible LDAP injection from unverified input for an attribute name. if (!LdapUtilities::isValidAttributeFormat($attribute)) { throw new LdapQueryException(sprintf('Attribute "%s" is not a valid name or OID.', $attribute)); } return $attribute; }
php
protected function getAttributeToQuery($alias) { $attribute = $this->getTranslatedAttribute($alias) ?: $this->getAttribute(); // This avoids possible LDAP injection from unverified input for an attribute name. if (!LdapUtilities::isValidAttributeFormat($attribute)) { throw new LdapQueryException(sprintf('Attribute "%s" is not a valid name or OID.', $attribute)); } return $attribute; }
[ "protected", "function", "getAttributeToQuery", "(", "$", "alias", ")", "{", "$", "attribute", "=", "$", "this", "->", "getTranslatedAttribute", "(", "$", "alias", ")", "?", ":", "$", "this", "->", "getAttribute", "(", ")", ";", "// This avoids possible LDAP injection from unverified input for an attribute name.", "if", "(", "!", "LdapUtilities", "::", "isValidAttributeFormat", "(", "$", "attribute", ")", ")", "{", "throw", "new", "LdapQueryException", "(", "sprintf", "(", "'Attribute \"%s\" is not a valid name or OID.'", ",", "$", "attribute", ")", ")", ";", "}", "return", "$", "attribute", ";", "}" ]
This will get the translated attribute or just the attribute if no schema translation was done. @param null|string $alias @return string @throws LdapQueryException
[ "This", "will", "get", "the", "translated", "attribute", "or", "just", "the", "attribute", "if", "no", "schema", "translation", "was", "done", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L334-L344
28,003
ldaptools/ldaptools
src/LdapTools/Query/Operator/BaseOperator.php
BaseOperator.getValueForQuery
protected function getValueForQuery($alias) { $value = $this->getConvertedValue($alias); return is_null($value) ? $this->getValue() : $value; }
php
protected function getValueForQuery($alias) { $value = $this->getConvertedValue($alias); return is_null($value) ? $this->getValue() : $value; }
[ "protected", "function", "getValueForQuery", "(", "$", "alias", ")", "{", "$", "value", "=", "$", "this", "->", "getConvertedValue", "(", "$", "alias", ")", ";", "return", "is_null", "(", "$", "value", ")", "?", "$", "this", "->", "getValue", "(", ")", ":", "$", "value", ";", "}" ]
Depending on whether a converter was used, get the value that should be used for the query. @param null|string $alias @return mixed
[ "Depending", "on", "whether", "a", "converter", "was", "used", "get", "the", "value", "that", "should", "be", "used", "for", "the", "query", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L352-L357
28,004
ldaptools/ldaptools
src/LdapTools/Factory/HydratorFactory.php
HydratorFactory.get
public function get($hydratorType) { if (self::TO_ARRAY == $hydratorType) { return new ArrayHydrator(); } elseif (self::TO_OBJECT == $hydratorType) { return new LdapObjectHydrator(); } else { throw new InvalidArgumentException(sprintf('Unknown hydrator type "%s".', $hydratorType)); } }
php
public function get($hydratorType) { if (self::TO_ARRAY == $hydratorType) { return new ArrayHydrator(); } elseif (self::TO_OBJECT == $hydratorType) { return new LdapObjectHydrator(); } else { throw new InvalidArgumentException(sprintf('Unknown hydrator type "%s".', $hydratorType)); } }
[ "public", "function", "get", "(", "$", "hydratorType", ")", "{", "if", "(", "self", "::", "TO_ARRAY", "==", "$", "hydratorType", ")", "{", "return", "new", "ArrayHydrator", "(", ")", ";", "}", "elseif", "(", "self", "::", "TO_OBJECT", "==", "$", "hydratorType", ")", "{", "return", "new", "LdapObjectHydrator", "(", ")", ";", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Unknown hydrator type \"%s\".'", ",", "$", "hydratorType", ")", ")", ";", "}", "}" ]
Get the hydrator by its type. @param string $hydratorType @return \LdapTools\Hydrator\HydratorInterface
[ "Get", "the", "hydrator", "by", "its", "type", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Factory/HydratorFactory.php#L40-L49
28,005
ldaptools/ldaptools
src/LdapTools/DomainConfiguration.php
DomainConfiguration.setLdapType
public function setLdapType($ldapType) { if (!defined('\LdapTools\Connection\LdapConnection::TYPE_'.strtoupper($ldapType))) { throw new InvalidArgumentException(sprintf('Invalid LDAP type "%s".', $ldapType)); } $this->config['ldapType'] = strtolower($ldapType); return $this; }
php
public function setLdapType($ldapType) { if (!defined('\LdapTools\Connection\LdapConnection::TYPE_'.strtoupper($ldapType))) { throw new InvalidArgumentException(sprintf('Invalid LDAP type "%s".', $ldapType)); } $this->config['ldapType'] = strtolower($ldapType); return $this; }
[ "public", "function", "setLdapType", "(", "$", "ldapType", ")", "{", "if", "(", "!", "defined", "(", "'\\LdapTools\\Connection\\LdapConnection::TYPE_'", ".", "strtoupper", "(", "$", "ldapType", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid LDAP type \"%s\".'", ",", "$", "ldapType", ")", ")", ";", "}", "$", "this", "->", "config", "[", "'ldapType'", "]", "=", "strtolower", "(", "$", "ldapType", ")", ";", "return", "$", "this", ";", "}" ]
Set the LDAP type for this domain. @param string $ldapType The LDAP type. @return $this
[ "Set", "the", "LDAP", "type", "for", "this", "domain", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/DomainConfiguration.php#L359-L367
28,006
ldaptools/ldaptools
src/LdapTools/DomainConfiguration.php
DomainConfiguration.load
public function load(array $config) { $config = $this->getParsedConfig( $config, $this->config, $this->yamlConfigMap, $this->required ); $this->setParsedConfig($config); return $this; }
php
public function load(array $config) { $config = $this->getParsedConfig( $config, $this->config, $this->yamlConfigMap, $this->required ); $this->setParsedConfig($config); return $this; }
[ "public", "function", "load", "(", "array", "$", "config", ")", "{", "$", "config", "=", "$", "this", "->", "getParsedConfig", "(", "$", "config", ",", "$", "this", "->", "config", ",", "$", "this", "->", "yamlConfigMap", ",", "$", "this", "->", "required", ")", ";", "$", "this", "->", "setParsedConfig", "(", "$", "config", ")", ";", "return", "$", "this", ";", "}" ]
Load a configuration from an array of values. The keys must be the same name as their YAML config names. @param array $config @return $this @throws ConfigurationException
[ "Load", "a", "configuration", "from", "an", "array", "of", "values", ".", "The", "keys", "must", "be", "the", "same", "name", "as", "their", "YAML", "config", "names", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/DomainConfiguration.php#L613-L624
28,007
ldaptools/ldaptools
src/LdapTools/DomainConfiguration.php
DomainConfiguration.isParsedConfigValid
protected function isParsedConfigValid(array $config) { $inConfig = count(array_intersect_key(array_flip($this->required), $config)); return $inConfig === count($this->required); }
php
protected function isParsedConfigValid(array $config) { $inConfig = count(array_intersect_key(array_flip($this->required), $config)); return $inConfig === count($this->required); }
[ "protected", "function", "isParsedConfigValid", "(", "array", "$", "config", ")", "{", "$", "inConfig", "=", "count", "(", "array_intersect_key", "(", "array_flip", "(", "$", "this", "->", "required", ")", ",", "$", "config", ")", ")", ";", "return", "$", "inConfig", "===", "count", "(", "$", "this", "->", "required", ")", ";", "}" ]
Checks whether all required values for the configuration have been set. @param array $config @return bool
[ "Checks", "whether", "all", "required", "values", "for", "the", "configuration", "have", "been", "set", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/DomainConfiguration.php#L632-L637
28,008
ldaptools/ldaptools
src/LdapTools/DomainConfiguration.php
DomainConfiguration.validateInteger
protected function validateInteger($value, $name) { if (filter_var($value, FILTER_VALIDATE_INT) === false) { throw new InvalidArgumentException(sprintf("The %s should be an integer.", $name)); } return $value; }
php
protected function validateInteger($value, $name) { if (filter_var($value, FILTER_VALIDATE_INT) === false) { throw new InvalidArgumentException(sprintf("The %s should be an integer.", $name)); } return $value; }
[ "protected", "function", "validateInteger", "(", "$", "value", ",", "$", "name", ")", "{", "if", "(", "filter_var", "(", "$", "value", ",", "FILTER_VALIDATE_INT", ")", "===", "false", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "\"The %s should be an integer.\"", ",", "$", "name", ")", ")", ";", "}", "return", "$", "value", ";", "}" ]
This is a helper since an integer could simply be passed as a string, which is still valid. @param mixed $value @param string $name @return int
[ "This", "is", "a", "helper", "since", "an", "integer", "could", "simply", "be", "passed", "as", "a", "string", "which", "is", "still", "valid", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/DomainConfiguration.php#L646-L653
28,009
ldaptools/ldaptools
src/LdapTools/Schema/LdapObjectSchema.php
LdapObjectSchema.setAttributeMap
public function setAttributeMap(array $attributeMap) { $this->attributeMap = $attributeMap; $this->lcAttributeNameMap = array_change_key_case($attributeMap); $this->lcAttributeValueMap = array_map('strtolower', $attributeMap); }
php
public function setAttributeMap(array $attributeMap) { $this->attributeMap = $attributeMap; $this->lcAttributeNameMap = array_change_key_case($attributeMap); $this->lcAttributeValueMap = array_map('strtolower', $attributeMap); }
[ "public", "function", "setAttributeMap", "(", "array", "$", "attributeMap", ")", "{", "$", "this", "->", "attributeMap", "=", "$", "attributeMap", ";", "$", "this", "->", "lcAttributeNameMap", "=", "array_change_key_case", "(", "$", "attributeMap", ")", ";", "$", "this", "->", "lcAttributeValueMap", "=", "array_map", "(", "'strtolower'", ",", "$", "attributeMap", ")", ";", "}" ]
Set the map of names to actual LDAP attribute names. @param array $attributeMap
[ "Set", "the", "map", "of", "names", "to", "actual", "LDAP", "attribute", "names", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/LdapObjectSchema.php#L169-L174
28,010
ldaptools/ldaptools
src/LdapTools/Schema/LdapObjectSchema.php
LdapObjectSchema.getConverter
public function getConverter($attributeName) { if (!$this->hasConverter($attributeName)) { throw new InvalidArgumentException(sprintf('No converter exists for attribute "%s".', $attributeName)); } return $this->lcConverterMap[strtolower($attributeName)]; }
php
public function getConverter($attributeName) { if (!$this->hasConverter($attributeName)) { throw new InvalidArgumentException(sprintf('No converter exists for attribute "%s".', $attributeName)); } return $this->lcConverterMap[strtolower($attributeName)]; }
[ "public", "function", "getConverter", "(", "$", "attributeName", ")", "{", "if", "(", "!", "$", "this", "->", "hasConverter", "(", "$", "attributeName", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'No converter exists for attribute \"%s\".'", ",", "$", "attributeName", ")", ")", ";", "}", "return", "$", "this", "->", "lcConverterMap", "[", "strtolower", "(", "$", "attributeName", ")", "]", ";", "}" ]
Get the name of the converter for an attribute. @param string $attributeName @return string
[ "Get", "the", "name", "of", "the", "converter", "for", "an", "attribute", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/LdapObjectSchema.php#L224-L231
28,011
ldaptools/ldaptools
src/LdapTools/Schema/LdapObjectSchema.php
LdapObjectSchema.getAttributeToLdap
public function getAttributeToLdap($attribute) { return $this->hasAttribute($attribute) ? $this->lcAttributeNameMap[strtolower($attribute)] : $attribute; }
php
public function getAttributeToLdap($attribute) { return $this->hasAttribute($attribute) ? $this->lcAttributeNameMap[strtolower($attribute)] : $attribute; }
[ "public", "function", "getAttributeToLdap", "(", "$", "attribute", ")", "{", "return", "$", "this", "->", "hasAttribute", "(", "$", "attribute", ")", "?", "$", "this", "->", "lcAttributeNameMap", "[", "strtolower", "(", "$", "attribute", ")", "]", ":", "$", "attribute", ";", "}" ]
Given an attribute name, this will get the attribute that LDAP is expecting for that name. @param string $attribute @return string
[ "Given", "an", "attribute", "name", "this", "will", "get", "the", "attribute", "that", "LDAP", "is", "expecting", "for", "that", "name", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/LdapObjectSchema.php#L333-L336
28,012
ldaptools/ldaptools
src/LdapTools/Schema/LdapObjectSchema.php
LdapObjectSchema.setConverterOptions
public function setConverterOptions($converter, $attribute, array $converterOptions) { if (!isset($this->converterOptions[$converter])) { $this->converterOptions[$converter] = []; } $this->converterOptions[$converter][strtolower($attribute)] = $converterOptions; }
php
public function setConverterOptions($converter, $attribute, array $converterOptions) { if (!isset($this->converterOptions[$converter])) { $this->converterOptions[$converter] = []; } $this->converterOptions[$converter][strtolower($attribute)] = $converterOptions; }
[ "public", "function", "setConverterOptions", "(", "$", "converter", ",", "$", "attribute", ",", "array", "$", "converterOptions", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "converterOptions", "[", "$", "converter", "]", ")", ")", "{", "$", "this", "->", "converterOptions", "[", "$", "converter", "]", "=", "[", "]", ";", "}", "$", "this", "->", "converterOptions", "[", "$", "converter", "]", "[", "strtolower", "(", "$", "attribute", ")", "]", "=", "$", "converterOptions", ";", "}" ]
Set any options to be passed to specific converters. @param string $converter @param string $attribute @param array $converterOptions
[ "Set", "any", "options", "to", "be", "passed", "to", "specific", "converters", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/LdapObjectSchema.php#L465-L471
28,013
ldaptools/ldaptools
src/LdapTools/Schema/LdapObjectSchema.php
LdapObjectSchema.getConverterOptions
public function getConverterOptions($converter, $attribute) { $lcAttr = strtolower($attribute); $options = []; if (isset($this->converterOptions[$converter]) && isset($this->converterOptions[$converter][$lcAttr])) { $options = $this->converterOptions[$converter][$lcAttr]; } return $options; }
php
public function getConverterOptions($converter, $attribute) { $lcAttr = strtolower($attribute); $options = []; if (isset($this->converterOptions[$converter]) && isset($this->converterOptions[$converter][$lcAttr])) { $options = $this->converterOptions[$converter][$lcAttr]; } return $options; }
[ "public", "function", "getConverterOptions", "(", "$", "converter", ",", "$", "attribute", ")", "{", "$", "lcAttr", "=", "strtolower", "(", "$", "attribute", ")", ";", "$", "options", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "converterOptions", "[", "$", "converter", "]", ")", "&&", "isset", "(", "$", "this", "->", "converterOptions", "[", "$", "converter", "]", "[", "$", "lcAttr", "]", ")", ")", "{", "$", "options", "=", "$", "this", "->", "converterOptions", "[", "$", "converter", "]", "[", "$", "lcAttr", "]", ";", "}", "return", "$", "options", ";", "}" ]
Get the array of converter options for a specific converter and attribute. @param string $converter @param string $attribute @return array
[ "Get", "the", "array", "of", "converter", "options", "for", "a", "specific", "converter", "and", "attribute", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/LdapObjectSchema.php#L480-L490
28,014
ldaptools/ldaptools
src/LdapTools/Ldif/Entry/LdifEntryAdd.php
LdifEntryAdd.addAttribute
public function addAttribute($attribute, $value) { $value = is_array($value) ? $value : [$value]; if (!isset($this->attributes[$attribute])) { $this->attributes[$attribute] = []; } foreach ($value as $attrValue) { $this->attributes[$attribute][] = $attrValue; } return $this; }
php
public function addAttribute($attribute, $value) { $value = is_array($value) ? $value : [$value]; if (!isset($this->attributes[$attribute])) { $this->attributes[$attribute] = []; } foreach ($value as $attrValue) { $this->attributes[$attribute][] = $attrValue; } return $this; }
[ "public", "function", "addAttribute", "(", "$", "attribute", ",", "$", "value", ")", "{", "$", "value", "=", "is_array", "(", "$", "value", ")", "?", "$", "value", ":", "[", "$", "value", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "attributes", "[", "$", "attribute", "]", ")", ")", "{", "$", "this", "->", "attributes", "[", "$", "attribute", "]", "=", "[", "]", ";", "}", "foreach", "(", "$", "value", "as", "$", "attrValue", ")", "{", "$", "this", "->", "attributes", "[", "$", "attribute", "]", "[", "]", "=", "$", "attrValue", ";", "}", "return", "$", "this", ";", "}" ]
Add an attribute that will be added to the entry going to LDAP. @param string $attribute @param mixed $value @return $this
[ "Add", "an", "attribute", "that", "will", "be", "added", "to", "the", "entry", "going", "to", "LDAP", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/Entry/LdifEntryAdd.php#L62-L74
28,015
ldaptools/ldaptools
src/LdapTools/Ldif/Entry/LdifEntryAdd.php
LdifEntryAdd.setAttributes
public function setAttributes(array $attributes) { $this->attributes = []; foreach ($attributes as $attribute => $value) { $this->addAttribute($attribute, $value); } return $this; }
php
public function setAttributes(array $attributes) { $this->attributes = []; foreach ($attributes as $attribute => $value) { $this->addAttribute($attribute, $value); } return $this; }
[ "public", "function", "setAttributes", "(", "array", "$", "attributes", ")", "{", "$", "this", "->", "attributes", "=", "[", "]", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute", "=>", "$", "value", ")", "{", "$", "this", "->", "addAttribute", "(", "$", "attribute", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the attributes that will be added to the entry going to LDAP. @param array $attributes @return $this
[ "Set", "the", "attributes", "that", "will", "be", "added", "to", "the", "entry", "going", "to", "LDAP", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/Entry/LdifEntryAdd.php#L82-L90
28,016
ldaptools/ldaptools
src/LdapTools/Security/FlagsSddlTrait.php
FlagsSddlTrait.getShortNames
public function getShortNames() { $names = []; $used = []; foreach (static::SHORT_NAME as $name => $value) { if ($this->has($value) && !in_array($value, $used)) { $names[] = $name; $used[] = $value; } } return $names; }
php
public function getShortNames() { $names = []; $used = []; foreach (static::SHORT_NAME as $name => $value) { if ($this->has($value) && !in_array($value, $used)) { $names[] = $name; $used[] = $value; } } return $names; }
[ "public", "function", "getShortNames", "(", ")", "{", "$", "names", "=", "[", "]", ";", "$", "used", "=", "[", "]", ";", "foreach", "(", "static", "::", "SHORT_NAME", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "value", ")", "&&", "!", "in_array", "(", "$", "value", ",", "$", "used", ")", ")", "{", "$", "names", "[", "]", "=", "$", "name", ";", "$", "used", "[", "]", "=", "$", "value", ";", "}", "}", "return", "$", "names", ";", "}" ]
Get the short names used in SDDL. @return array
[ "Get", "the", "short", "names", "used", "in", "SDDL", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/FlagsSddlTrait.php#L27-L40
28,017
ldaptools/ldaptools
src/LdapTools/Resolver/AttributeNameResolver.php
AttributeNameResolver.toLdap
public function toLdap(array $entry) { $toLdap = []; foreach ($entry as $attribute => $value) { $toLdap[$this->schema->getAttributeToLdap($attribute)] = $value; } return $toLdap; }
php
public function toLdap(array $entry) { $toLdap = []; foreach ($entry as $attribute => $value) { $toLdap[$this->schema->getAttributeToLdap($attribute)] = $value; } return $toLdap; }
[ "public", "function", "toLdap", "(", "array", "$", "entry", ")", "{", "$", "toLdap", "=", "[", "]", ";", "foreach", "(", "$", "entry", "as", "$", "attribute", "=>", "$", "value", ")", "{", "$", "toLdap", "[", "$", "this", "->", "schema", "->", "getAttributeToLdap", "(", "$", "attribute", ")", "]", "=", "$", "value", ";", "}", "return", "$", "toLdap", ";", "}" ]
Convert values to LDAP. @param array $entry The LDAP entry. @return array
[ "Convert", "values", "to", "LDAP", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/AttributeNameResolver.php#L73-L82
28,018
ldaptools/ldaptools
src/LdapTools/Resolver/AttributeNameResolver.php
AttributeNameResolver.arraySearchGetValue
public static function arraySearchGetValue($needle, array $haystack) { $lcNeedle = strtolower($needle); foreach ($haystack as $value) { if ($lcNeedle == strtolower($value)) { return $value; } } return null; }
php
public static function arraySearchGetValue($needle, array $haystack) { $lcNeedle = strtolower($needle); foreach ($haystack as $value) { if ($lcNeedle == strtolower($value)) { return $value; } } return null; }
[ "public", "static", "function", "arraySearchGetValue", "(", "$", "needle", ",", "array", "$", "haystack", ")", "{", "$", "lcNeedle", "=", "strtolower", "(", "$", "needle", ")", ";", "foreach", "(", "$", "haystack", "as", "$", "value", ")", "{", "if", "(", "$", "lcNeedle", "==", "strtolower", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "}", "return", "null", ";", "}" ]
Given an array value determine if it exists in the array and return the value as it is in the array. @param string $needle @param array $haystack @return string|null
[ "Given", "an", "array", "value", "determine", "if", "it", "exists", "in", "the", "array", "and", "return", "the", "value", "as", "it", "is", "in", "the", "array", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/AttributeNameResolver.php#L91-L102
28,019
ldaptools/ldaptools
src/LdapTools/Resolver/AttributeNameResolver.php
AttributeNameResolver.addDnFromLdapIfNotPresent
protected function addDnFromLdapIfNotPresent(array $newEntry, array $entry) { if (!isset($newEntry['dn']) && isset($entry['dn'])) { $newEntry['dn'] = $entry['dn']; } return $newEntry; }
php
protected function addDnFromLdapIfNotPresent(array $newEntry, array $entry) { if (!isset($newEntry['dn']) && isset($entry['dn'])) { $newEntry['dn'] = $entry['dn']; } return $newEntry; }
[ "protected", "function", "addDnFromLdapIfNotPresent", "(", "array", "$", "newEntry", ",", "array", "$", "entry", ")", "{", "if", "(", "!", "isset", "(", "$", "newEntry", "[", "'dn'", "]", ")", "&&", "isset", "(", "$", "entry", "[", "'dn'", "]", ")", ")", "{", "$", "newEntry", "[", "'dn'", "]", "=", "$", "entry", "[", "'dn'", "]", ";", "}", "return", "$", "newEntry", ";", "}" ]
The DN attribute is returned by PHP on all LDAP search operations, regardless of selected attributes, and is used in many functions. So add it to the results even if it wasn't selected for. @param array $newEntry @param array $entry @return array
[ "The", "DN", "attribute", "is", "returned", "by", "PHP", "on", "all", "LDAP", "search", "operations", "regardless", "of", "selected", "attributes", "and", "is", "used", "in", "many", "functions", ".", "So", "add", "it", "to", "the", "results", "even", "if", "it", "wasn", "t", "selected", "for", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/AttributeNameResolver.php#L112-L119
28,020
ldaptools/ldaptools
src/LdapTools/Resolver/AttributeNameResolver.php
AttributeNameResolver.selectedButNotPartOfEntry
protected function selectedButNotPartOfEntry($attribute, array $entry) { $lcAttribute = strtolower($attribute); $inSelectedAttributes = in_array($lcAttribute, array_map('strtolower', $this->selectedAttributes)); $existsInEntry = array_key_exists($lcAttribute, array_change_key_case($entry)); return ($inSelectedAttributes && !$existsInEntry); }
php
protected function selectedButNotPartOfEntry($attribute, array $entry) { $lcAttribute = strtolower($attribute); $inSelectedAttributes = in_array($lcAttribute, array_map('strtolower', $this->selectedAttributes)); $existsInEntry = array_key_exists($lcAttribute, array_change_key_case($entry)); return ($inSelectedAttributes && !$existsInEntry); }
[ "protected", "function", "selectedButNotPartOfEntry", "(", "$", "attribute", ",", "array", "$", "entry", ")", "{", "$", "lcAttribute", "=", "strtolower", "(", "$", "attribute", ")", ";", "$", "inSelectedAttributes", "=", "in_array", "(", "$", "lcAttribute", ",", "array_map", "(", "'strtolower'", ",", "$", "this", "->", "selectedAttributes", ")", ")", ";", "$", "existsInEntry", "=", "array_key_exists", "(", "$", "lcAttribute", ",", "array_change_key_case", "(", "$", "entry", ")", ")", ";", "return", "(", "$", "inSelectedAttributes", "&&", "!", "$", "existsInEntry", ")", ";", "}" ]
Check whether the attribute name was selected to be returned but is not yet part of the entry. Adjusts the check to be case insensitive. @param string $attribute @param array $entry @return bool
[ "Check", "whether", "the", "attribute", "name", "was", "selected", "to", "be", "returned", "but", "is", "not", "yet", "part", "of", "the", "entry", ".", "Adjusts", "the", "check", "to", "be", "case", "insensitive", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/AttributeNameResolver.php#L129-L137
28,021
ldaptools/ldaptools
src/LdapTools/Resolver/AttributeNameResolver.php
AttributeNameResolver.setMappedNames
protected function setMappedNames(array $newEntry, $attribute, $value) { // Get all names mapped to this LDAP attribute name... if (!$this->schema->hasNamesMappedToAttribute($attribute)) { return $newEntry; } $mappedNames = $this->schema->getNamesMappedToAttribute($attribute); foreach ($mappedNames as $mappedName) { // Any names specifically selected for should be in the result array... if ($this->selectedButNotPartOfEntry($mappedName, $newEntry)) { $newEntry[self::arraySearchGetValue($mappedName, $this->selectedAttributes)] = $value; } } return $newEntry; }
php
protected function setMappedNames(array $newEntry, $attribute, $value) { // Get all names mapped to this LDAP attribute name... if (!$this->schema->hasNamesMappedToAttribute($attribute)) { return $newEntry; } $mappedNames = $this->schema->getNamesMappedToAttribute($attribute); foreach ($mappedNames as $mappedName) { // Any names specifically selected for should be in the result array... if ($this->selectedButNotPartOfEntry($mappedName, $newEntry)) { $newEntry[self::arraySearchGetValue($mappedName, $this->selectedAttributes)] = $value; } } return $newEntry; }
[ "protected", "function", "setMappedNames", "(", "array", "$", "newEntry", ",", "$", "attribute", ",", "$", "value", ")", "{", "// Get all names mapped to this LDAP attribute name...", "if", "(", "!", "$", "this", "->", "schema", "->", "hasNamesMappedToAttribute", "(", "$", "attribute", ")", ")", "{", "return", "$", "newEntry", ";", "}", "$", "mappedNames", "=", "$", "this", "->", "schema", "->", "getNamesMappedToAttribute", "(", "$", "attribute", ")", ";", "foreach", "(", "$", "mappedNames", "as", "$", "mappedName", ")", "{", "// Any names specifically selected for should be in the result array...", "if", "(", "$", "this", "->", "selectedButNotPartOfEntry", "(", "$", "mappedName", ",", "$", "newEntry", ")", ")", "{", "$", "newEntry", "[", "self", "::", "arraySearchGetValue", "(", "$", "mappedName", ",", "$", "this", "->", "selectedAttributes", ")", "]", "=", "$", "value", ";", "}", "}", "return", "$", "newEntry", ";", "}" ]
Set all the names mapped to a single attribute from LDAP. This helps account for multiple mappings used for different purposes. @param array $newEntry @param string $attribute @param array|string $value @return mixed
[ "Set", "all", "the", "names", "mapped", "to", "a", "single", "attribute", "from", "LDAP", ".", "This", "helps", "account", "for", "multiple", "mappings", "used", "for", "different", "purposes", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/AttributeNameResolver.php#L148-L164
28,022
ldaptools/ldaptools
src/LdapTools/Resolver/AttributeNameResolver.php
AttributeNameResolver.getSelectedAttributes
protected function getSelectedAttributes(array $selected, array $entry) { if (count($selected) === 1 && $selected[0] == '*' && !$this->schema) { $selected = array_keys($entry); } elseif (count($selected) === 1 && $selected[0] == '*' && $this->schema) { $selected = array_unique(array_merge(array_keys($this->schema->getAttributeMap()), array_keys($entry))); } return $selected; }
php
protected function getSelectedAttributes(array $selected, array $entry) { if (count($selected) === 1 && $selected[0] == '*' && !$this->schema) { $selected = array_keys($entry); } elseif (count($selected) === 1 && $selected[0] == '*' && $this->schema) { $selected = array_unique(array_merge(array_keys($this->schema->getAttributeMap()), array_keys($entry))); } return $selected; }
[ "protected", "function", "getSelectedAttributes", "(", "array", "$", "selected", ",", "array", "$", "entry", ")", "{", "if", "(", "count", "(", "$", "selected", ")", "===", "1", "&&", "$", "selected", "[", "0", "]", "==", "'*'", "&&", "!", "$", "this", "->", "schema", ")", "{", "$", "selected", "=", "array_keys", "(", "$", "entry", ")", ";", "}", "elseif", "(", "count", "(", "$", "selected", ")", "===", "1", "&&", "$", "selected", "[", "0", "]", "==", "'*'", "&&", "$", "this", "->", "schema", ")", "{", "$", "selected", "=", "array_unique", "(", "array_merge", "(", "array_keys", "(", "$", "this", "->", "schema", "->", "getAttributeMap", "(", ")", ")", ",", "array_keys", "(", "$", "entry", ")", ")", ")", ";", "}", "return", "$", "selected", ";", "}" ]
Determine what attributes should be selected. This accounts for a query wanting all attributes. @param array $selected @param array $entry @return array
[ "Determine", "what", "attributes", "should", "be", "selected", ".", "This", "accounts", "for", "a", "query", "wanting", "all", "attributes", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/AttributeNameResolver.php#L173-L182
28,023
ldaptools/ldaptools
src/LdapTools/Ldif/LdifParser.php
LdifParser.parse
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; }
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", ";", "}" ]
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", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifParser.php#L102-L125
28,024
ldaptools/ldaptools
src/LdapTools/Ldif/LdifParser.php
LdifParser.parseEntry
protected function parseEntry() { $entry = $this->parseCommonDirectives($this->getKeyAndValue($this->currentLine())[1]); if (!empty($this->commentQueue)) { $entry->addComment(...$this->commentQueue); $this->commentQueue = []; } // Nothing further to do with a simple deletion... if ($entry instanceof LdifEntryDelete) { return $entry; } while (!$this->isEndOfLdif() && !$this->isStartOfEntry()) { if ($this->isComment()) { $entry->addComment(substr($this->currentLine(), 1)); $this->nextLine(); } elseif ($this->isEndOfEntry()) { break; } else { list($key, $value) = $this->getKeyAndValue($this->currentLine()); $this->addDirectiveToEntry($key, $value, $entry); $this->nextLine(); } } return $entry; }
php
protected function parseEntry() { $entry = $this->parseCommonDirectives($this->getKeyAndValue($this->currentLine())[1]); if (!empty($this->commentQueue)) { $entry->addComment(...$this->commentQueue); $this->commentQueue = []; } // Nothing further to do with a simple deletion... if ($entry instanceof LdifEntryDelete) { return $entry; } while (!$this->isEndOfLdif() && !$this->isStartOfEntry()) { if ($this->isComment()) { $entry->addComment(substr($this->currentLine(), 1)); $this->nextLine(); } elseif ($this->isEndOfEntry()) { break; } else { list($key, $value) = $this->getKeyAndValue($this->currentLine()); $this->addDirectiveToEntry($key, $value, $entry); $this->nextLine(); } } return $entry; }
[ "protected", "function", "parseEntry", "(", ")", "{", "$", "entry", "=", "$", "this", "->", "parseCommonDirectives", "(", "$", "this", "->", "getKeyAndValue", "(", "$", "this", "->", "currentLine", "(", ")", ")", "[", "1", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "commentQueue", ")", ")", "{", "$", "entry", "->", "addComment", "(", "...", "$", "this", "->", "commentQueue", ")", ";", "$", "this", "->", "commentQueue", "=", "[", "]", ";", "}", "// Nothing further to do with a simple deletion...", "if", "(", "$", "entry", "instanceof", "LdifEntryDelete", ")", "{", "return", "$", "entry", ";", "}", "while", "(", "!", "$", "this", "->", "isEndOfLdif", "(", ")", "&&", "!", "$", "this", "->", "isStartOfEntry", "(", ")", ")", "{", "if", "(", "$", "this", "->", "isComment", "(", ")", ")", "{", "$", "entry", "->", "addComment", "(", "substr", "(", "$", "this", "->", "currentLine", "(", ")", ",", "1", ")", ")", ";", "$", "this", "->", "nextLine", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "isEndOfEntry", "(", ")", ")", "{", "break", ";", "}", "else", "{", "list", "(", "$", "key", ",", "$", "value", ")", "=", "$", "this", "->", "getKeyAndValue", "(", "$", "this", "->", "currentLine", "(", ")", ")", ";", "$", "this", "->", "addDirectiveToEntry", "(", "$", "key", ",", "$", "value", ",", "$", "entry", ")", ";", "$", "this", "->", "nextLine", "(", ")", ";", "}", "}", "return", "$", "entry", ";", "}" ]
Parse an entry from the DN position until we reach the start of the next entry. Return the entry that was parsed. @return LdifEntryInterface
[ "Parse", "an", "entry", "from", "the", "DN", "position", "until", "we", "reach", "the", "start", "of", "the", "next", "entry", ".", "Return", "the", "entry", "that", "was", "parsed", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifParser.php#L183-L211
28,025
ldaptools/ldaptools
src/LdapTools/Ldif/LdifParser.php
LdifParser.getLdifEntryObject
protected function getLdifEntryObject($dn, $changeType) { if (!array_key_exists($changeType, $this->changeTypeMap)) { $this->throwException(sprintf('The changetype "%s" is invalid', $changeType)); } return new $this->changeTypeMap[$changeType]($dn); }
php
protected function getLdifEntryObject($dn, $changeType) { if (!array_key_exists($changeType, $this->changeTypeMap)) { $this->throwException(sprintf('The changetype "%s" is invalid', $changeType)); } return new $this->changeTypeMap[$changeType]($dn); }
[ "protected", "function", "getLdifEntryObject", "(", "$", "dn", ",", "$", "changeType", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "changeType", ",", "$", "this", "->", "changeTypeMap", ")", ")", "{", "$", "this", "->", "throwException", "(", "sprintf", "(", "'The changetype \"%s\" is invalid'", ",", "$", "changeType", ")", ")", ";", "}", "return", "new", "$", "this", "->", "changeTypeMap", "[", "$", "changeType", "]", "(", "$", "dn", ")", ";", "}" ]
Get the LdifEntry for the changetype. @param string $dn @param string $changeType @return LdifEntryInterface @throws LdifParserException
[ "Get", "the", "LdifEntry", "for", "the", "changetype", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifParser.php#L265-L272
28,026
ldaptools/ldaptools
src/LdapTools/Ldif/LdifParser.php
LdifParser.startsWith
protected function startsWith($value, $line = null) { if (is_null($line)) { $line = $this->currentLine(); } return (substr($line, 0, strlen($value)) === $value); }
php
protected function startsWith($value, $line = null) { if (is_null($line)) { $line = $this->currentLine(); } return (substr($line, 0, strlen($value)) === $value); }
[ "protected", "function", "startsWith", "(", "$", "value", ",", "$", "line", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "line", ")", ")", "{", "$", "line", "=", "$", "this", "->", "currentLine", "(", ")", ";", "}", "return", "(", "substr", "(", "$", "line", ",", "0", ",", "strlen", "(", "$", "value", ")", ")", "===", "$", "value", ")", ";", "}" ]
Check if the current line starts with a specific value. @param string $value @param null|string $line @return bool
[ "Check", "if", "the", "current", "line", "starts", "with", "a", "specific", "value", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifParser.php#L310-L317
28,027
ldaptools/ldaptools
src/LdapTools/Ldif/LdifParser.php
LdifParser.getContinuedValues
protected function getContinuedValues($value) { while ($this->isContinuedValue($this->nextLine(false))) { $value .= substr($this->nextLine(), 1); } return $value; }
php
protected function getContinuedValues($value) { while ($this->isContinuedValue($this->nextLine(false))) { $value .= substr($this->nextLine(), 1); } return $value; }
[ "protected", "function", "getContinuedValues", "(", "$", "value", ")", "{", "while", "(", "$", "this", "->", "isContinuedValue", "(", "$", "this", "->", "nextLine", "(", "false", ")", ")", ")", "{", "$", "value", ".=", "substr", "(", "$", "this", "->", "nextLine", "(", ")", ",", "1", ")", ";", "}", "return", "$", "value", ";", "}" ]
Check for any continued values and concatenate them into one. @param $value @return string
[ "Check", "for", "any", "continued", "values", "and", "concatenate", "them", "into", "one", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifParser.php#L419-L426
28,028
ldaptools/ldaptools
src/LdapTools/Ldif/LdifParser.php
LdifParser.getValueFromUrl
protected function getValueFromUrl($url) { $type = substr($url, 0, strpos($url, Ldif::KEY_VALUE_SEPARATOR)); if (!$this->hasUrlLoader($type)) { $this->throwException(sprintf('Cannot find a URL loader for type "%s"', $type)); } try { return $this->urlLoaders[$type]->load($url); } catch (LdifUrlLoaderException $e) { $this->throwException($e->getMessage()); } }
php
protected function getValueFromUrl($url) { $type = substr($url, 0, strpos($url, Ldif::KEY_VALUE_SEPARATOR)); if (!$this->hasUrlLoader($type)) { $this->throwException(sprintf('Cannot find a URL loader for type "%s"', $type)); } try { return $this->urlLoaders[$type]->load($url); } catch (LdifUrlLoaderException $e) { $this->throwException($e->getMessage()); } }
[ "protected", "function", "getValueFromUrl", "(", "$", "url", ")", "{", "$", "type", "=", "substr", "(", "$", "url", ",", "0", ",", "strpos", "(", "$", "url", ",", "Ldif", "::", "KEY_VALUE_SEPARATOR", ")", ")", ";", "if", "(", "!", "$", "this", "->", "hasUrlLoader", "(", "$", "type", ")", ")", "{", "$", "this", "->", "throwException", "(", "sprintf", "(", "'Cannot find a URL loader for type \"%s\"'", ",", "$", "type", ")", ")", ";", "}", "try", "{", "return", "$", "this", "->", "urlLoaders", "[", "$", "type", "]", "->", "load", "(", "$", "url", ")", ";", "}", "catch", "(", "LdifUrlLoaderException", "$", "e", ")", "{", "$", "this", "->", "throwException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Get the value of the URL data via a UrlLoader. @param string $url @return string
[ "Get", "the", "value", "of", "the", "URL", "data", "via", "a", "UrlLoader", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifParser.php#L434-L447
28,029
ldaptools/ldaptools
src/LdapTools/Ldif/LdifParser.php
LdifParser.getLdapControl
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; }
php
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; }
[ "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", ";", "}" ]
Validate a control directive and get the value for the control and the criticality. @param string $value @return LdapControl @throws LdifParserException
[ "Validate", "a", "control", "directive", "and", "get", "the", "value", "for", "the", "control", "and", "the", "criticality", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifParser.php#L520-L542
28,030
ldaptools/ldaptools
src/LdapTools/Ldif/LdifParser.php
LdifParser.getBoolFromStringBool
protected function getBoolFromStringBool($value) { if (!($value == 'true' || $value == 'false')) { $this->throwException(sprintf('Expected "true" or "false" but got %s', $value)); } return $value === 'true' ? true : false; }
php
protected function getBoolFromStringBool($value) { if (!($value == 'true' || $value == 'false')) { $this->throwException(sprintf('Expected "true" or "false" but got %s', $value)); } return $value === 'true' ? true : false; }
[ "protected", "function", "getBoolFromStringBool", "(", "$", "value", ")", "{", "if", "(", "!", "(", "$", "value", "==", "'true'", "||", "$", "value", "==", "'false'", ")", ")", "{", "$", "this", "->", "throwException", "(", "sprintf", "(", "'Expected \"true\" or \"false\" but got %s'", ",", "$", "value", ")", ")", ";", "}", "return", "$", "value", "===", "'true'", "?", "true", ":", "false", ";", "}" ]
Convert an expected string "true" or "false" to bool. @param string $value @return bool @throws LdifParserException
[ "Convert", "an", "expected", "string", "true", "or", "false", "to", "bool", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifParser.php#L615-L622
28,031
ldaptools/ldaptools
src/LdapTools/Ldif/LdifParser.php
LdifParser.getBoolFromStringInt
protected function getBoolFromStringInt($value) { if (!($value == '0' || $value == '1')) { $this->throwException(sprintf('Expected "0" or "1" but got: %s', $value)); } return (bool) $value; }
php
protected function getBoolFromStringInt($value) { if (!($value == '0' || $value == '1')) { $this->throwException(sprintf('Expected "0" or "1" but got: %s', $value)); } return (bool) $value; }
[ "protected", "function", "getBoolFromStringInt", "(", "$", "value", ")", "{", "if", "(", "!", "(", "$", "value", "==", "'0'", "||", "$", "value", "==", "'1'", ")", ")", "{", "$", "this", "->", "throwException", "(", "sprintf", "(", "'Expected \"0\" or \"1\" but got: %s'", ",", "$", "value", ")", ")", ";", "}", "return", "(", "bool", ")", "$", "value", ";", "}" ]
Convert an expected string "0" or "1" to bool. @param string $value @return bool @throws LdifParserException
[ "Convert", "an", "expected", "string", "0", "or", "1", "to", "bool", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifParser.php#L631-L638
28,032
ldaptools/ldaptools
src/LdapTools/Ldif/LdifParser.php
LdifParser.addCommentToQueueOrLdif
protected function addCommentToQueueOrLdif(Ldif $ldif) { $comment = $this->getContinuedValues(substr($this->currentLine(), 1)); // Remove the single space from the start of a comment, but leave the others intact. if ($this->startsWith(' ', $comment)) { $comment = substr($comment, 1); } // If we already have an entry added to LDIF, then the comment should go in the queue for the next entry. if (count($ldif->getEntries()) > 0) { $this->commentQueue[] = $comment; // Check the section of the LDIF to look for an empty line. If so, assume it's for a future entry. } elseif (array_search('', array_slice($this->lines, 0, $this->line))) { $this->commentQueue[] = $comment; // No empty lines and we have not reached an entry yet, so this should be a comment for the LDIF overall. } else { $ldif->addComment($comment); } }
php
protected function addCommentToQueueOrLdif(Ldif $ldif) { $comment = $this->getContinuedValues(substr($this->currentLine(), 1)); // Remove the single space from the start of a comment, but leave the others intact. if ($this->startsWith(' ', $comment)) { $comment = substr($comment, 1); } // If we already have an entry added to LDIF, then the comment should go in the queue for the next entry. if (count($ldif->getEntries()) > 0) { $this->commentQueue[] = $comment; // Check the section of the LDIF to look for an empty line. If so, assume it's for a future entry. } elseif (array_search('', array_slice($this->lines, 0, $this->line))) { $this->commentQueue[] = $comment; // No empty lines and we have not reached an entry yet, so this should be a comment for the LDIF overall. } else { $ldif->addComment($comment); } }
[ "protected", "function", "addCommentToQueueOrLdif", "(", "Ldif", "$", "ldif", ")", "{", "$", "comment", "=", "$", "this", "->", "getContinuedValues", "(", "substr", "(", "$", "this", "->", "currentLine", "(", ")", ",", "1", ")", ")", ";", "// Remove the single space from the start of a comment, but leave the others intact.", "if", "(", "$", "this", "->", "startsWith", "(", "' '", ",", "$", "comment", ")", ")", "{", "$", "comment", "=", "substr", "(", "$", "comment", ",", "1", ")", ";", "}", "// If we already have an entry added to LDIF, then the comment should go in the queue for the next entry.", "if", "(", "count", "(", "$", "ldif", "->", "getEntries", "(", ")", ")", ">", "0", ")", "{", "$", "this", "->", "commentQueue", "[", "]", "=", "$", "comment", ";", "// Check the section of the LDIF to look for an empty line. If so, assume it's for a future entry.", "}", "elseif", "(", "array_search", "(", "''", ",", "array_slice", "(", "$", "this", "->", "lines", ",", "0", ",", "$", "this", "->", "line", ")", ")", ")", "{", "$", "this", "->", "commentQueue", "[", "]", "=", "$", "comment", ";", "// No empty lines and we have not reached an entry yet, so this should be a comment for the LDIF overall.", "}", "else", "{", "$", "ldif", "->", "addComment", "(", "$", "comment", ")", ";", "}", "}" ]
Determine whether the comment should be added to the LDIF itself, or if it's a comment for an entry within the LDIF. If it's for an entry in the LDIF, then we make the assumption that we an empty line separates comments between the LDIF comments overall and the start of a comment for an entry. This seems like the most reasonable way to do it, though it still may not be perfect. @param \LdapTools\Ldif\Ldif $ldif
[ "Determine", "whether", "the", "comment", "should", "be", "added", "to", "the", "LDIF", "itself", "or", "if", "it", "s", "a", "comment", "for", "an", "entry", "within", "the", "LDIF", ".", "If", "it", "s", "for", "an", "entry", "in", "the", "LDIF", "then", "we", "make", "the", "assumption", "that", "we", "an", "empty", "line", "separates", "comments", "between", "the", "LDIF", "comments", "overall", "and", "the", "start", "of", "a", "comment", "for", "an", "entry", ".", "This", "seems", "like", "the", "most", "reasonable", "way", "to", "do", "it", "though", "it", "still", "may", "not", "be", "perfect", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifParser.php#L659-L678
28,033
ldaptools/ldaptools
src/LdapTools/Object/LdapObject.php
LdapObject.has
public function has($attribute, $value = null) { if (!array_key_exists(strtolower($attribute), array_change_key_case($this->attributes))) { return false; } return is_null($value) ?: $this->attributeHasValue($attribute, $value); }
php
public function has($attribute, $value = null) { if (!array_key_exists(strtolower($attribute), array_change_key_case($this->attributes))) { return false; } return is_null($value) ?: $this->attributeHasValue($attribute, $value); }
[ "public", "function", "has", "(", "$", "attribute", ",", "$", "value", "=", "null", ")", "{", "if", "(", "!", "array_key_exists", "(", "strtolower", "(", "$", "attribute", ")", ",", "array_change_key_case", "(", "$", "this", "->", "attributes", ")", ")", ")", "{", "return", "false", ";", "}", "return", "is_null", "(", "$", "value", ")", "?", ":", "$", "this", "->", "attributeHasValue", "(", "$", "attribute", ",", "$", "value", ")", ";", "}" ]
Check to see if a specific attribute exists. Optionally check if it exists with a specific value. @param string $attribute @param mixed $value @return bool
[ "Check", "to", "see", "if", "a", "specific", "attribute", "exists", ".", "Optionally", "check", "if", "it", "exists", "with", "a", "specific", "value", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObject.php#L90-L97
28,034
ldaptools/ldaptools
src/LdapTools/Object/LdapObject.php
LdapObject.get
public function get($attribute, $default = null) { return $this->has($attribute) ? array_change_key_case($this->attributes)[strtolower($attribute)] : $default; }
php
public function get($attribute, $default = null) { return $this->has($attribute) ? array_change_key_case($this->attributes)[strtolower($attribute)] : $default; }
[ "public", "function", "get", "(", "$", "attribute", ",", "$", "default", "=", "null", ")", "{", "return", "$", "this", "->", "has", "(", "$", "attribute", ")", "?", "array_change_key_case", "(", "$", "this", "->", "attributes", ")", "[", "strtolower", "(", "$", "attribute", ")", "]", ":", "$", "default", ";", "}" ]
Get the value of an attribute. An attribute with multiple values will return an array of values. If the attribute does not exist it will return null by default. Pass an optional default value to return something other than null. @param string $attribute @param mixed $default @return mixed
[ "Get", "the", "value", "of", "an", "attribute", ".", "An", "attribute", "with", "multiple", "values", "will", "return", "an", "array", "of", "values", ".", "If", "the", "attribute", "does", "not", "exist", "it", "will", "return", "null", "by", "default", ".", "Pass", "an", "optional", "default", "value", "to", "return", "something", "other", "than", "null", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObject.php#L107-L110
28,035
ldaptools/ldaptools
src/LdapTools/Object/LdapObject.php
LdapObject.reset
public function reset(...$attributes) { foreach ($attributes as $attribute) { if ($this->has($attribute)) { $attribute = $this->resolveAttributeName($attribute); unset($this->attributes[$attribute]); } $this->batches->add(new Batch(Batch::TYPE['REMOVE_ALL'], $attribute)); } return $this; }
php
public function reset(...$attributes) { foreach ($attributes as $attribute) { if ($this->has($attribute)) { $attribute = $this->resolveAttributeName($attribute); unset($this->attributes[$attribute]); } $this->batches->add(new Batch(Batch::TYPE['REMOVE_ALL'], $attribute)); } return $this; }
[ "public", "function", "reset", "(", "...", "$", "attributes", ")", "{", "foreach", "(", "$", "attributes", "as", "$", "attribute", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "attribute", ")", ")", "{", "$", "attribute", "=", "$", "this", "->", "resolveAttributeName", "(", "$", "attribute", ")", ";", "unset", "(", "$", "this", "->", "attributes", "[", "$", "attribute", "]", ")", ";", "}", "$", "this", "->", "batches", "->", "add", "(", "new", "Batch", "(", "Batch", "::", "TYPE", "[", "'REMOVE_ALL'", "]", ",", "$", "attribute", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Resets the attribute, which effectively removes any values it may have. @param string[] ...$attributes @return $this
[ "Resets", "the", "attribute", "which", "effectively", "removes", "any", "values", "it", "may", "have", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObject.php#L164-L175
28,036
ldaptools/ldaptools
src/LdapTools/Object/LdapObject.php
LdapObject.add
public function add($attribute, ...$values) { foreach ($values as $value) { if ($this->has($attribute)) { $attribute = $this->resolveAttributeName($attribute); $this->attributes[$attribute] = $this->addAttributeValue($this->attributes[$attribute], $value); } else { $this->attributes[$attribute] = $value; } $this->batches->add(new Batch(Batch::TYPE['ADD'], $attribute, $value)); } return $this; }
php
public function add($attribute, ...$values) { foreach ($values as $value) { if ($this->has($attribute)) { $attribute = $this->resolveAttributeName($attribute); $this->attributes[$attribute] = $this->addAttributeValue($this->attributes[$attribute], $value); } else { $this->attributes[$attribute] = $value; } $this->batches->add(new Batch(Batch::TYPE['ADD'], $attribute, $value)); } return $this; }
[ "public", "function", "add", "(", "$", "attribute", ",", "...", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "attribute", ")", ")", "{", "$", "attribute", "=", "$", "this", "->", "resolveAttributeName", "(", "$", "attribute", ")", ";", "$", "this", "->", "attributes", "[", "$", "attribute", "]", "=", "$", "this", "->", "addAttributeValue", "(", "$", "this", "->", "attributes", "[", "$", "attribute", "]", ",", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "attributes", "[", "$", "attribute", "]", "=", "$", "value", ";", "}", "$", "this", "->", "batches", "->", "add", "(", "new", "Batch", "(", "Batch", "::", "TYPE", "[", "'ADD'", "]", ",", "$", "attribute", ",", "$", "value", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add an additional value, or values, to an attribute. @param string $attribute @param mixed[] ...$values @return $this
[ "Add", "an", "additional", "value", "or", "values", "to", "an", "attribute", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObject.php#L184-L197
28,037
ldaptools/ldaptools
src/LdapTools/Object/LdapObject.php
LdapObject.attributeHasValue
protected function attributeHasValue($attribute, $value) { $attribute = $this->resolveAttributeName($attribute); if (is_array($this->attributes[$attribute])) { return in_array($value, $this->attributes[$attribute]); } else { return ($this->attributes[$attribute] == $value); } }
php
protected function attributeHasValue($attribute, $value) { $attribute = $this->resolveAttributeName($attribute); if (is_array($this->attributes[$attribute])) { return in_array($value, $this->attributes[$attribute]); } else { return ($this->attributes[$attribute] == $value); } }
[ "protected", "function", "attributeHasValue", "(", "$", "attribute", ",", "$", "value", ")", "{", "$", "attribute", "=", "$", "this", "->", "resolveAttributeName", "(", "$", "attribute", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "attributes", "[", "$", "attribute", "]", ")", ")", "{", "return", "in_array", "(", "$", "value", ",", "$", "this", "->", "attributes", "[", "$", "attribute", "]", ")", ";", "}", "else", "{", "return", "(", "$", "this", "->", "attributes", "[", "$", "attribute", "]", "==", "$", "value", ")", ";", "}", "}" ]
Check if an attribute has a specific value. Called only when the attribute is known to exist already. @param string $attribute @param mixed $value @return bool
[ "Check", "if", "an", "attribute", "has", "a", "specific", "value", ".", "Called", "only", "when", "the", "attribute", "is", "known", "to", "exist", "already", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObject.php#L322-L331
28,038
ldaptools/ldaptools
src/LdapTools/Object/LdapObject.php
LdapObject.resolveAttributeName
protected function resolveAttributeName($attribute) { $result = preg_grep("/^$attribute$/i", array_keys($this->attributes)); if (empty($result)) { throw new InvalidArgumentException(sprintf('Unable to resolve attribute "%s".', $attribute)); } return reset($result); }
php
protected function resolveAttributeName($attribute) { $result = preg_grep("/^$attribute$/i", array_keys($this->attributes)); if (empty($result)) { throw new InvalidArgumentException(sprintf('Unable to resolve attribute "%s".', $attribute)); } return reset($result); }
[ "protected", "function", "resolveAttributeName", "(", "$", "attribute", ")", "{", "$", "result", "=", "preg_grep", "(", "\"/^$attribute$/i\"", ",", "array_keys", "(", "$", "this", "->", "attributes", ")", ")", ";", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Unable to resolve attribute \"%s\".'", ",", "$", "attribute", ")", ")", ";", "}", "return", "reset", "(", "$", "result", ")", ";", "}" ]
Retrieve the attribute in the case it exists in the array. @param string $attribute @return string
[ "Retrieve", "the", "attribute", "in", "the", "case", "it", "exists", "in", "the", "array", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObject.php#L339-L347
28,039
ldaptools/ldaptools
src/LdapTools/Object/LdapObject.php
LdapObject.removeAttributeValue
protected function removeAttributeValue($value, $valueToRemove) { $valueToRemove = is_array($valueToRemove) ? $valueToRemove : [ $valueToRemove ]; foreach ($valueToRemove as $remove) { if (is_array($value) && (($key = array_search($remove, $value)) !== false)) { unset($value[$key]); } elseif (!is_array($value) && ($value == $remove)) { $value = ''; } } return $value; }
php
protected function removeAttributeValue($value, $valueToRemove) { $valueToRemove = is_array($valueToRemove) ? $valueToRemove : [ $valueToRemove ]; foreach ($valueToRemove as $remove) { if (is_array($value) && (($key = array_search($remove, $value)) !== false)) { unset($value[$key]); } elseif (!is_array($value) && ($value == $remove)) { $value = ''; } } return $value; }
[ "protected", "function", "removeAttributeValue", "(", "$", "value", ",", "$", "valueToRemove", ")", "{", "$", "valueToRemove", "=", "is_array", "(", "$", "valueToRemove", ")", "?", "$", "valueToRemove", ":", "[", "$", "valueToRemove", "]", ";", "foreach", "(", "$", "valueToRemove", "as", "$", "remove", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "&&", "(", "(", "$", "key", "=", "array_search", "(", "$", "remove", ",", "$", "value", ")", ")", "!==", "false", ")", ")", "{", "unset", "(", "$", "value", "[", "$", "key", "]", ")", ";", "}", "elseif", "(", "!", "is_array", "(", "$", "value", ")", "&&", "(", "$", "value", "==", "$", "remove", ")", ")", "{", "$", "value", "=", "''", ";", "}", "}", "return", "$", "value", ";", "}" ]
Given the original value, remove if it's present. @param mixed $value @param mixed $valueToRemove @return mixed
[ "Given", "the", "original", "value", "remove", "if", "it", "s", "present", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObject.php#L356-L369
28,040
ldaptools/ldaptools
src/LdapTools/Object/LdapObject.php
LdapObject.addAttributeValue
protected function addAttributeValue($value, $valueToAdd) { $valueToAdd = is_array($valueToAdd) ? $valueToAdd : [ $valueToAdd ]; $value = is_array($value) ? $value : [ $value ]; return array_merge($value, $valueToAdd); }
php
protected function addAttributeValue($value, $valueToAdd) { $valueToAdd = is_array($valueToAdd) ? $valueToAdd : [ $valueToAdd ]; $value = is_array($value) ? $value : [ $value ]; return array_merge($value, $valueToAdd); }
[ "protected", "function", "addAttributeValue", "(", "$", "value", ",", "$", "valueToAdd", ")", "{", "$", "valueToAdd", "=", "is_array", "(", "$", "valueToAdd", ")", "?", "$", "valueToAdd", ":", "[", "$", "valueToAdd", "]", ";", "$", "value", "=", "is_array", "(", "$", "value", ")", "?", "$", "value", ":", "[", "$", "value", "]", ";", "return", "array_merge", "(", "$", "value", ",", "$", "valueToAdd", ")", ";", "}" ]
Adds an additional value to an existing LDAP attribute value. @param mixed $value @param mixed $valueToAdd @return array
[ "Adds", "an", "additional", "value", "to", "an", "existing", "LDAP", "attribute", "value", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObject.php#L378-L384
28,041
ldaptools/ldaptools
src/LdapTools/Operation/QueryOperation.php
QueryOperation.setScope
public function setScope($scope) { if (!in_array($scope, self::SCOPE)) { throw new LdapQueryException(sprintf( 'Scope type "%s" is invalid. See the QueryOperation::SCOPE[] constant for valid types.', $scope )); } $this->properties['scope'] = $scope; return $this; }
php
public function setScope($scope) { if (!in_array($scope, self::SCOPE)) { throw new LdapQueryException(sprintf( 'Scope type "%s" is invalid. See the QueryOperation::SCOPE[] constant for valid types.', $scope )); } $this->properties['scope'] = $scope; return $this; }
[ "public", "function", "setScope", "(", "$", "scope", ")", "{", "if", "(", "!", "in_array", "(", "$", "scope", ",", "self", "::", "SCOPE", ")", ")", "{", "throw", "new", "LdapQueryException", "(", "sprintf", "(", "'Scope type \"%s\" is invalid. See the QueryOperation::SCOPE[] constant for valid types.'", ",", "$", "scope", ")", ")", ";", "}", "$", "this", "->", "properties", "[", "'scope'", "]", "=", "$", "scope", ";", "return", "$", "this", ";", "}" ]
Set the scope for the LDAP query operation. @param $scope @return $this @throws LdapQueryException
[ "Set", "the", "scope", "for", "the", "LDAP", "query", "operation", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/QueryOperation.php#L135-L145
28,042
ldaptools/ldaptools
src/LdapTools/Enums/AD/ResponseCode.php
ResponseCode.getMessageForError
public static function getMessageForError($value) { if (self::isValidName($value)) { $value = self::getNameValue($value); } return isset(self::$messages[$value]) ? self::$messages[$value] : null; }
php
public static function getMessageForError($value) { if (self::isValidName($value)) { $value = self::getNameValue($value); } return isset(self::$messages[$value]) ? self::$messages[$value] : null; }
[ "public", "static", "function", "getMessageForError", "(", "$", "value", ")", "{", "if", "(", "self", "::", "isValidName", "(", "$", "value", ")", ")", "{", "$", "value", "=", "self", "::", "getNameValue", "(", "$", "value", ")", ";", "}", "return", "isset", "(", "self", "::", "$", "messages", "[", "$", "value", "]", ")", "?", "self", "::", "$", "messages", "[", "$", "value", "]", ":", "null", ";", "}" ]
Get the helpful error message for a specific error if it exists. @param mixed $value @return string|null
[ "Get", "the", "helpful", "error", "message", "for", "a", "specific", "error", "if", "it", "exists", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Enums/AD/ResponseCode.php#L144-L151
28,043
ldaptools/ldaptools
src/LdapTools/Ldif/LdifStringBuilderTrait.php
LdifStringBuilderTrait.addCommentsToString
protected function addCommentsToString($ldif) { foreach ($this->comments as $comment) { $ldif .= Ldif::COMMENT.' '.$this->getValueForLine($comment).$this->lineEnding; } return $ldif; }
php
protected function addCommentsToString($ldif) { foreach ($this->comments as $comment) { $ldif .= Ldif::COMMENT.' '.$this->getValueForLine($comment).$this->lineEnding; } return $ldif; }
[ "protected", "function", "addCommentsToString", "(", "$", "ldif", ")", "{", "foreach", "(", "$", "this", "->", "comments", "as", "$", "comment", ")", "{", "$", "ldif", ".=", "Ldif", "::", "COMMENT", ".", "' '", ".", "$", "this", "->", "getValueForLine", "(", "$", "comment", ")", ".", "$", "this", "->", "lineEnding", ";", "}", "return", "$", "ldif", ";", "}" ]
Add any specified comments to the generated LDIF. @param string $ldif @return string
[ "Add", "any", "specified", "comments", "to", "the", "generated", "LDIF", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifStringBuilderTrait.php#L145-L152
28,044
ldaptools/ldaptools
src/LdapTools/Ldif/LdifStringBuilderTrait.php
LdifStringBuilderTrait.getLdifLine
protected function getLdifLine($directive, $value) { $separator = Ldif::KEY_VALUE_SEPARATOR; // Per the RFC, any value starting with a space should be base64 encoded if ((substr($value, 0, strlen(' ')) === ' ')) { $separator .= Ldif::KEY_VALUE_SEPARATOR; $value = base64_encode($value); } return $directive.$separator.' '.$this->getValueForLine($value).$this->lineEnding; }
php
protected function getLdifLine($directive, $value) { $separator = Ldif::KEY_VALUE_SEPARATOR; // Per the RFC, any value starting with a space should be base64 encoded if ((substr($value, 0, strlen(' ')) === ' ')) { $separator .= Ldif::KEY_VALUE_SEPARATOR; $value = base64_encode($value); } return $directive.$separator.' '.$this->getValueForLine($value).$this->lineEnding; }
[ "protected", "function", "getLdifLine", "(", "$", "directive", ",", "$", "value", ")", "{", "$", "separator", "=", "Ldif", "::", "KEY_VALUE_SEPARATOR", ";", "// Per the RFC, any value starting with a space should be base64 encoded", "if", "(", "(", "substr", "(", "$", "value", ",", "0", ",", "strlen", "(", "' '", ")", ")", "===", "' '", ")", ")", "{", "$", "separator", ".=", "Ldif", "::", "KEY_VALUE_SEPARATOR", ";", "$", "value", "=", "base64_encode", "(", "$", "value", ")", ";", "}", "return", "$", "directive", ".", "$", "separator", ".", "' '", ".", "$", "this", "->", "getValueForLine", "(", "$", "value", ")", ".", "$", "this", "->", "lineEnding", ";", "}" ]
Construct a single line of the LDIF for a given directive and value. @param string $directive @param string $value @return string
[ "Construct", "a", "single", "line", "of", "the", "LDIF", "for", "a", "given", "directive", "and", "value", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifStringBuilderTrait.php#L161-L172
28,045
ldaptools/ldaptools
src/LdapTools/Ldif/LdifStringBuilderTrait.php
LdifStringBuilderTrait.getValueForLine
protected function getValueForLine($value) { /** * Is this the correct way to do line folding? If a folded line starts/ends with a space should the value, * and this every line, be base64 encoded? Reading the RFC this does not seem clear. */ if ($this->lineFolding) { $value = implode( $this->lineEnding." ", str_split($value, $this->maxLineLength) ); } return $value; }
php
protected function getValueForLine($value) { /** * Is this the correct way to do line folding? If a folded line starts/ends with a space should the value, * and this every line, be base64 encoded? Reading the RFC this does not seem clear. */ if ($this->lineFolding) { $value = implode( $this->lineEnding." ", str_split($value, $this->maxLineLength) ); } return $value; }
[ "protected", "function", "getValueForLine", "(", "$", "value", ")", "{", "/**\n * Is this the correct way to do line folding? If a folded line starts/ends with a space should the value,\n * and this every line, be base64 encoded? Reading the RFC this does not seem clear.\n */", "if", "(", "$", "this", "->", "lineFolding", ")", "{", "$", "value", "=", "implode", "(", "$", "this", "->", "lineEnding", ".", "\" \"", ",", "str_split", "(", "$", "value", ",", "$", "this", "->", "maxLineLength", ")", ")", ";", "}", "return", "$", "value", ";", "}" ]
Gets the value for the line while taking into account any line folding set. @param $value @return string
[ "Gets", "the", "value", "for", "the", "line", "while", "taking", "into", "account", "any", "line", "folding", "set", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifStringBuilderTrait.php#L180-L194
28,046
ldaptools/ldaptools
src/LdapTools/Utilities/MBString.php
MBString.ord
public static function ord($string) { if (self::isMbstringLoaded()) { $result = unpack('N', mb_convert_encoding($string, 'UCS-4BE', 'UTF-8')); if (is_array($result) === true) { return $result[1]; } } return ord($string); }
php
public static function ord($string) { if (self::isMbstringLoaded()) { $result = unpack('N', mb_convert_encoding($string, 'UCS-4BE', 'UTF-8')); if (is_array($result) === true) { return $result[1]; } } return ord($string); }
[ "public", "static", "function", "ord", "(", "$", "string", ")", "{", "if", "(", "self", "::", "isMbstringLoaded", "(", ")", ")", "{", "$", "result", "=", "unpack", "(", "'N'", ",", "mb_convert_encoding", "(", "$", "string", ",", "'UCS-4BE'", ",", "'UTF-8'", ")", ")", ";", "if", "(", "is_array", "(", "$", "result", ")", "===", "true", ")", "{", "return", "$", "result", "[", "1", "]", ";", "}", "}", "return", "ord", "(", "$", "string", ")", ";", "}" ]
Get the integer value of a specific character. @param $string @return int
[ "Get", "the", "integer", "value", "of", "a", "specific", "character", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/MBString.php#L42-L52
28,047
ldaptools/ldaptools
src/LdapTools/Utilities/MBString.php
MBString.compare
public static function compare($value1, $value2) { if (self::isIntlLoaded()) { return self::getCollator()->compare($value1, $value2); } return strnatcmp($value1, $value2); }
php
public static function compare($value1, $value2) { if (self::isIntlLoaded()) { return self::getCollator()->compare($value1, $value2); } return strnatcmp($value1, $value2); }
[ "public", "static", "function", "compare", "(", "$", "value1", ",", "$", "value2", ")", "{", "if", "(", "self", "::", "isIntlLoaded", "(", ")", ")", "{", "return", "self", "::", "getCollator", "(", ")", "->", "compare", "(", "$", "value1", ",", "$", "value2", ")", ";", "}", "return", "strnatcmp", "(", "$", "value1", ",", "$", "value2", ")", ";", "}" ]
Performs a comparison between two values and returns an integer result, like strnatcmp. @param string $value1 @param string $value2 @return int
[ "Performs", "a", "comparison", "between", "two", "values", "and", "returns", "an", "integer", "result", "like", "strnatcmp", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/MBString.php#L87-L94
28,048
ldaptools/ldaptools
src/LdapTools/Utilities/MBString.php
MBString.array_change_value_case
public static function array_change_value_case(array $values) { $newValues = []; foreach ($values as $key => $value) { $newValues[$key] = self::strtolower($value); } return $newValues; }
php
public static function array_change_value_case(array $values) { $newValues = []; foreach ($values as $key => $value) { $newValues[$key] = self::strtolower($value); } return $newValues; }
[ "public", "static", "function", "array_change_value_case", "(", "array", "$", "values", ")", "{", "$", "newValues", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "newValues", "[", "$", "key", "]", "=", "self", "::", "strtolower", "(", "$", "value", ")", ";", "}", "return", "$", "newValues", ";", "}" ]
Change the values in an array to lower-case values. @param array $values @return array
[ "Change", "the", "values", "in", "an", "array", "to", "lower", "-", "case", "values", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/MBString.php#L117-L126
28,049
ldaptools/ldaptools
src/LdapTools/Security/SecurityDescriptor.php
SecurityDescriptor.setOwner
public function setOwner($owner) { $this->owner = $owner instanceof SID ? $owner : new SID($owner); return $this; }
php
public function setOwner($owner) { $this->owner = $owner instanceof SID ? $owner : new SID($owner); return $this; }
[ "public", "function", "setOwner", "(", "$", "owner", ")", "{", "$", "this", "->", "owner", "=", "$", "owner", "instanceof", "SID", "?", "$", "owner", ":", "new", "SID", "(", "$", "owner", ")", ";", "return", "$", "this", ";", "}" ]
Set the owner SID for the security descriptor. @param SID|string $owner @return $this
[ "Set", "the", "owner", "SID", "for", "the", "security", "descriptor", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/SecurityDescriptor.php#L133-L138
28,050
ldaptools/ldaptools
src/LdapTools/Security/SecurityDescriptor.php
SecurityDescriptor.setGroup
public function setGroup($group) { $this->group = $group instanceof SID ? $group : new SID($group); return $this; }
php
public function setGroup($group) { $this->group = $group instanceof SID ? $group : new SID($group); return $this; }
[ "public", "function", "setGroup", "(", "$", "group", ")", "{", "$", "this", "->", "group", "=", "$", "group", "instanceof", "SID", "?", "$", "group", ":", "new", "SID", "(", "$", "group", ")", ";", "return", "$", "this", ";", "}" ]
Set the group SID for the security descriptor. @param SID|string $group @return $this
[ "Set", "the", "group", "SID", "for", "the", "security", "descriptor", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/SecurityDescriptor.php#L156-L161
28,051
ldaptools/ldaptools
src/LdapTools/Security/SecurityDescriptor.php
SecurityDescriptor.setDacl
public function setDacl(Dacl $dacl = null) { $this->dacl = $dacl; return $this->toggleAclPresent((bool) $dacl, Dacl::SDDL_CHAR); }
php
public function setDacl(Dacl $dacl = null) { $this->dacl = $dacl; return $this->toggleAclPresent((bool) $dacl, Dacl::SDDL_CHAR); }
[ "public", "function", "setDacl", "(", "Dacl", "$", "dacl", "=", "null", ")", "{", "$", "this", "->", "dacl", "=", "$", "dacl", ";", "return", "$", "this", "->", "toggleAclPresent", "(", "(", "bool", ")", "$", "dacl", ",", "Dacl", "::", "SDDL_CHAR", ")", ";", "}" ]
Set the Discretionary ACL. @param Dacl $dacl @return $this
[ "Set", "the", "Discretionary", "ACL", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/SecurityDescriptor.php#L189-L194
28,052
ldaptools/ldaptools
src/LdapTools/Security/SecurityDescriptor.php
SecurityDescriptor.setSacl
public function setSacl(Sacl $sacl = null) { $this->sacl = $sacl; return $this->toggleAclPresent((bool) $sacl, Sacl::SDDL_CHAR); }
php
public function setSacl(Sacl $sacl = null) { $this->sacl = $sacl; return $this->toggleAclPresent((bool) $sacl, Sacl::SDDL_CHAR); }
[ "public", "function", "setSacl", "(", "Sacl", "$", "sacl", "=", "null", ")", "{", "$", "this", "->", "sacl", "=", "$", "sacl", ";", "return", "$", "this", "->", "toggleAclPresent", "(", "(", "bool", ")", "$", "sacl", ",", "Sacl", "::", "SDDL_CHAR", ")", ";", "}" ]
Set the System ACL. @param Sacl $sacl @return $this
[ "Set", "the", "System", "ACL", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/SecurityDescriptor.php#L212-L217
28,053
ldaptools/ldaptools
src/LdapTools/Security/SecurityDescriptor.php
SecurityDescriptor.toBinary
public function toBinary($canonicalize = true) { $offsetOwner = 0; $offsetGroup = 0; $offsetDacl = 0; $offsetSacl = 0; $owner = $this->owner ? $this->owner->toBinary() : null; $group = $this->group ? $this->group->toBinary() : null; $dacl = $this->dacl ? $this->dacl->toBinary($canonicalize) : null; $sacl = $this->sacl ? $this->sacl->toBinary() : null; /** * According the the MS docs, the order of the elements is not important. And indeed, I have found no rhyme or * reason as to how the owner/group/sacl/dacl elements are ordered in the security descriptor. As long as they * point to the correct offset where the element is located then it will work. But the order seems unpredictable * as far as coming from AD/Exchange/etc. */ $offset = 40; if ($owner) { $offsetOwner = $offset; $offset += strlen(bin2hex($owner)); } if ($group) { $offsetGroup = $offset; $offset += strlen(bin2hex($group)); } if ($sacl) { $offsetSacl = $offset; $offset += strlen(bin2hex($sacl)); } if ($dacl) { $offsetDacl = $offset; } return pack( 'C1C1v1V1V1V1V1', $this->revision, $this->rmControlFlags->getValue(), $this->controlFlags->getValue(), ($offsetOwner / 2), ($offsetGroup / 2), ($offsetSacl / 2), ($offsetDacl / 2) ).$owner.$group.$sacl.$dacl; }
php
public function toBinary($canonicalize = true) { $offsetOwner = 0; $offsetGroup = 0; $offsetDacl = 0; $offsetSacl = 0; $owner = $this->owner ? $this->owner->toBinary() : null; $group = $this->group ? $this->group->toBinary() : null; $dacl = $this->dacl ? $this->dacl->toBinary($canonicalize) : null; $sacl = $this->sacl ? $this->sacl->toBinary() : null; /** * According the the MS docs, the order of the elements is not important. And indeed, I have found no rhyme or * reason as to how the owner/group/sacl/dacl elements are ordered in the security descriptor. As long as they * point to the correct offset where the element is located then it will work. But the order seems unpredictable * as far as coming from AD/Exchange/etc. */ $offset = 40; if ($owner) { $offsetOwner = $offset; $offset += strlen(bin2hex($owner)); } if ($group) { $offsetGroup = $offset; $offset += strlen(bin2hex($group)); } if ($sacl) { $offsetSacl = $offset; $offset += strlen(bin2hex($sacl)); } if ($dacl) { $offsetDacl = $offset; } return pack( 'C1C1v1V1V1V1V1', $this->revision, $this->rmControlFlags->getValue(), $this->controlFlags->getValue(), ($offsetOwner / 2), ($offsetGroup / 2), ($offsetSacl / 2), ($offsetDacl / 2) ).$owner.$group.$sacl.$dacl; }
[ "public", "function", "toBinary", "(", "$", "canonicalize", "=", "true", ")", "{", "$", "offsetOwner", "=", "0", ";", "$", "offsetGroup", "=", "0", ";", "$", "offsetDacl", "=", "0", ";", "$", "offsetSacl", "=", "0", ";", "$", "owner", "=", "$", "this", "->", "owner", "?", "$", "this", "->", "owner", "->", "toBinary", "(", ")", ":", "null", ";", "$", "group", "=", "$", "this", "->", "group", "?", "$", "this", "->", "group", "->", "toBinary", "(", ")", ":", "null", ";", "$", "dacl", "=", "$", "this", "->", "dacl", "?", "$", "this", "->", "dacl", "->", "toBinary", "(", "$", "canonicalize", ")", ":", "null", ";", "$", "sacl", "=", "$", "this", "->", "sacl", "?", "$", "this", "->", "sacl", "->", "toBinary", "(", ")", ":", "null", ";", "/**\n * According the the MS docs, the order of the elements is not important. And indeed, I have found no rhyme or\n * reason as to how the owner/group/sacl/dacl elements are ordered in the security descriptor. As long as they\n * point to the correct offset where the element is located then it will work. But the order seems unpredictable\n * as far as coming from AD/Exchange/etc.\n */", "$", "offset", "=", "40", ";", "if", "(", "$", "owner", ")", "{", "$", "offsetOwner", "=", "$", "offset", ";", "$", "offset", "+=", "strlen", "(", "bin2hex", "(", "$", "owner", ")", ")", ";", "}", "if", "(", "$", "group", ")", "{", "$", "offsetGroup", "=", "$", "offset", ";", "$", "offset", "+=", "strlen", "(", "bin2hex", "(", "$", "group", ")", ")", ";", "}", "if", "(", "$", "sacl", ")", "{", "$", "offsetSacl", "=", "$", "offset", ";", "$", "offset", "+=", "strlen", "(", "bin2hex", "(", "$", "sacl", ")", ")", ";", "}", "if", "(", "$", "dacl", ")", "{", "$", "offsetDacl", "=", "$", "offset", ";", "}", "return", "pack", "(", "'C1C1v1V1V1V1V1'", ",", "$", "this", "->", "revision", ",", "$", "this", "->", "rmControlFlags", "->", "getValue", "(", ")", ",", "$", "this", "->", "controlFlags", "->", "getValue", "(", ")", ",", "(", "$", "offsetOwner", "/", "2", ")", ",", "(", "$", "offsetGroup", "/", "2", ")", ",", "(", "$", "offsetSacl", "/", "2", ")", ",", "(", "$", "offsetDacl", "/", "2", ")", ")", ".", "$", "owner", ".", "$", "group", ".", "$", "sacl", ".", "$", "dacl", ";", "}" ]
Get the binary string form of the security descriptor. @param bool $canonicalize Whether or not to canonicalize the DACL @return string
[ "Get", "the", "binary", "string", "form", "of", "the", "security", "descriptor", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/SecurityDescriptor.php#L225-L269
28,054
ldaptools/ldaptools
src/LdapTools/Security/SecurityDescriptor.php
SecurityDescriptor.toSddl
public function toSddl($canonicalize = true) { // These will always be present in the SDDL... $sddl = 'O:'.($this->owner->getShortName() ?: $this->owner).'G:'.($this->group->getShortName() ?: $this->group); foreach ([$this->dacl, $this->sacl] as $acl) { // It should be omitted if empty or not set... if ($acl && count($acl->getAces()) > 0) { $sddl .= $acl->getSddlIdentifier().':'.$this->getAclSddlFlags($acl); $sddl .= $acl instanceof Dacl ? $acl->toSddl($canonicalize) : $acl->toSddl(); } } return $sddl; }
php
public function toSddl($canonicalize = true) { // These will always be present in the SDDL... $sddl = 'O:'.($this->owner->getShortName() ?: $this->owner).'G:'.($this->group->getShortName() ?: $this->group); foreach ([$this->dacl, $this->sacl] as $acl) { // It should be omitted if empty or not set... if ($acl && count($acl->getAces()) > 0) { $sddl .= $acl->getSddlIdentifier().':'.$this->getAclSddlFlags($acl); $sddl .= $acl instanceof Dacl ? $acl->toSddl($canonicalize) : $acl->toSddl(); } } return $sddl; }
[ "public", "function", "toSddl", "(", "$", "canonicalize", "=", "true", ")", "{", "// These will always be present in the SDDL...", "$", "sddl", "=", "'O:'", ".", "(", "$", "this", "->", "owner", "->", "getShortName", "(", ")", "?", ":", "$", "this", "->", "owner", ")", ".", "'G:'", ".", "(", "$", "this", "->", "group", "->", "getShortName", "(", ")", "?", ":", "$", "this", "->", "group", ")", ";", "foreach", "(", "[", "$", "this", "->", "dacl", ",", "$", "this", "->", "sacl", "]", "as", "$", "acl", ")", "{", "// It should be omitted if empty or not set...", "if", "(", "$", "acl", "&&", "count", "(", "$", "acl", "->", "getAces", "(", ")", ")", ">", "0", ")", "{", "$", "sddl", ".=", "$", "acl", "->", "getSddlIdentifier", "(", ")", ".", "':'", ".", "$", "this", "->", "getAclSddlFlags", "(", "$", "acl", ")", ";", "$", "sddl", ".=", "$", "acl", "instanceof", "Dacl", "?", "$", "acl", "->", "toSddl", "(", "$", "canonicalize", ")", ":", "$", "acl", "->", "toSddl", "(", ")", ";", "}", "}", "return", "$", "sddl", ";", "}" ]
Get the SDDL string format that represents this Security Descriptor and everything it contains. @param bool $canonicalize Whether or not to canonicalize the DACL @return string
[ "Get", "the", "SDDL", "string", "format", "that", "represents", "this", "Security", "Descriptor", "and", "everything", "it", "contains", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/SecurityDescriptor.php#L277-L291
28,055
ldaptools/ldaptools
src/LdapTools/AttributeConverter/ConvertGroupMembership.php
ConvertGroupMembership.createOperationsFromValues
protected function createOperationsFromValues(array $values) { // In the case of a 'set' or 'reset' operation all current group membership should be removed. if ($this->shouldRemoveCurrentGroups()) { $this->removeCurrentGroups(); } // Only if this is not a reset operation, otherwise there is nothing left to do. if (!($this->getOperationType() == AttributeConverterInterface::TYPE_MODIFY && $this->getBatch()->isTypeRemoveAll())) { $batchType = $this->getBatchTypeForOperation(); foreach ($values as $value) { $this->addOperation(parent::toLdap($value), $batchType); } } }
php
protected function createOperationsFromValues(array $values) { // In the case of a 'set' or 'reset' operation all current group membership should be removed. if ($this->shouldRemoveCurrentGroups()) { $this->removeCurrentGroups(); } // Only if this is not a reset operation, otherwise there is nothing left to do. if (!($this->getOperationType() == AttributeConverterInterface::TYPE_MODIFY && $this->getBatch()->isTypeRemoveAll())) { $batchType = $this->getBatchTypeForOperation(); foreach ($values as $value) { $this->addOperation(parent::toLdap($value), $batchType); } } }
[ "protected", "function", "createOperationsFromValues", "(", "array", "$", "values", ")", "{", "// In the case of a 'set' or 'reset' operation all current group membership should be removed.", "if", "(", "$", "this", "->", "shouldRemoveCurrentGroups", "(", ")", ")", "{", "$", "this", "->", "removeCurrentGroups", "(", ")", ";", "}", "// Only if this is not a reset operation, otherwise there is nothing left to do.", "if", "(", "!", "(", "$", "this", "->", "getOperationType", "(", ")", "==", "AttributeConverterInterface", "::", "TYPE_MODIFY", "&&", "$", "this", "->", "getBatch", "(", ")", "->", "isTypeRemoveAll", "(", ")", ")", ")", "{", "$", "batchType", "=", "$", "this", "->", "getBatchTypeForOperation", "(", ")", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "this", "->", "addOperation", "(", "parent", "::", "toLdap", "(", "$", "value", ")", ",", "$", "batchType", ")", ";", "}", "}", "}" ]
Given the set of array values create the correct operation. @param array $values @throws \LdapTools\Exception\AttributeConverterException
[ "Given", "the", "set", "of", "array", "values", "create", "the", "correct", "operation", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/AttributeConverter/ConvertGroupMembership.php#L78-L91
28,056
ldaptools/ldaptools
src/LdapTools/AttributeConverter/ConvertGroupMembership.php
ConvertGroupMembership.addOperation
protected function addOperation($dn, $batchType) { $collection = new BatchCollection($dn); $valueDn = $this->getDn(); // The DN is unknown in the case of an add, as value/parameter resolution most occur first. If there is a better // way to do this I'm not sure what it would be. The batch will resolve closures when producing an array to ldap. if ($this->getOperationType() == AttributeConverterInterface::TYPE_CREATE) { /** @var AddOperation $parentOp */ $parentOp = $this->getOperation(); $valueDn = function () use ($parentOp) { return $parentOp->getDn(); }; } $collection->add(new Batch($batchType, $this->options['to_attribute'], $valueDn)); $operation = new BatchModifyOperation($dn, $collection); $this->operation->addPostOperation($operation); }
php
protected function addOperation($dn, $batchType) { $collection = new BatchCollection($dn); $valueDn = $this->getDn(); // The DN is unknown in the case of an add, as value/parameter resolution most occur first. If there is a better // way to do this I'm not sure what it would be. The batch will resolve closures when producing an array to ldap. if ($this->getOperationType() == AttributeConverterInterface::TYPE_CREATE) { /** @var AddOperation $parentOp */ $parentOp = $this->getOperation(); $valueDn = function () use ($parentOp) { return $parentOp->getDn(); }; } $collection->add(new Batch($batchType, $this->options['to_attribute'], $valueDn)); $operation = new BatchModifyOperation($dn, $collection); $this->operation->addPostOperation($operation); }
[ "protected", "function", "addOperation", "(", "$", "dn", ",", "$", "batchType", ")", "{", "$", "collection", "=", "new", "BatchCollection", "(", "$", "dn", ")", ";", "$", "valueDn", "=", "$", "this", "->", "getDn", "(", ")", ";", "// The DN is unknown in the case of an add, as value/parameter resolution most occur first. If there is a better", "// way to do this I'm not sure what it would be. The batch will resolve closures when producing an array to ldap.", "if", "(", "$", "this", "->", "getOperationType", "(", ")", "==", "AttributeConverterInterface", "::", "TYPE_CREATE", ")", "{", "/** @var AddOperation $parentOp */", "$", "parentOp", "=", "$", "this", "->", "getOperation", "(", ")", ";", "$", "valueDn", "=", "function", "(", ")", "use", "(", "$", "parentOp", ")", "{", "return", "$", "parentOp", "->", "getDn", "(", ")", ";", "}", ";", "}", "$", "collection", "->", "add", "(", "new", "Batch", "(", "$", "batchType", ",", "$", "this", "->", "options", "[", "'to_attribute'", "]", ",", "$", "valueDn", ")", ")", ";", "$", "operation", "=", "new", "BatchModifyOperation", "(", "$", "dn", ",", "$", "collection", ")", ";", "$", "this", "->", "operation", "->", "addPostOperation", "(", "$", "operation", ")", ";", "}" ]
Add the correct operation for the action as a post operation to the current operation. @param string $dn @param int $batchType @throws \LdapTools\Exception\AttributeConverterException
[ "Add", "the", "correct", "operation", "for", "the", "action", "as", "a", "post", "operation", "to", "the", "current", "operation", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/AttributeConverter/ConvertGroupMembership.php#L100-L118
28,057
ldaptools/ldaptools
src/LdapTools/AttributeConverter/ConvertGroupMembership.php
ConvertGroupMembership.removeCurrentGroups
protected function removeCurrentGroups() { $valuesToRemove = $this->getCurrentLdapAttributeValue($this->options['from_attribute']); $valuesToRemove = is_null($valuesToRemove) ? [] : $valuesToRemove; $valuesToRemove = is_array($valuesToRemove) ? $valuesToRemove : [$valuesToRemove]; foreach ($valuesToRemove as $value) { $this->addOperation(parent::toLdap($value), Batch::TYPE['REMOVE']); }
php
protected function removeCurrentGroups() { $valuesToRemove = $this->getCurrentLdapAttributeValue($this->options['from_attribute']); $valuesToRemove = is_null($valuesToRemove) ? [] : $valuesToRemove; $valuesToRemove = is_array($valuesToRemove) ? $valuesToRemove : [$valuesToRemove]; foreach ($valuesToRemove as $value) { $this->addOperation(parent::toLdap($value), Batch::TYPE['REMOVE']); }
[ "protected", "function", "removeCurrentGroups", "(", ")", "{", "$", "valuesToRemove", "=", "$", "this", "->", "getCurrentLdapAttributeValue", "(", "$", "this", "->", "options", "[", "'from_attribute'", "]", ")", ";", "$", "valuesToRemove", "=", "is_null", "(", "$", "valuesToRemove", ")", "?", "[", "]", ":", "$", "valuesToRemove", ";", "$", "valuesToRemove", "=", "is_array", "(", "$", "valuesToRemove", ")", "?", "$", "valuesToRemove", ":", "[", "$", "valuesToRemove", "]", ";", "foreach", "(", "$", "valuesToRemove", "as", "$", "value", ")", "{", "$", "this", "->", "addOperation", "(", "parent", "::", "toLdap", "(", "$", "value", ")", ",", "Batch", "::", "TYPE", "", "[", "'REMOVE'", "]", ")", ";", "}" ]
Gets the current group membership and generates operations to remove them all. @throws \LdapTools\Exception\AttributeConverterException
[ "Gets", "the", "current", "group", "membership", "and", "generates", "operations", "to", "remove", "them", "all", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/AttributeConverter/ConvertGroupMembership.php#L134-L142
28,058
ldaptools/ldaptools
src/LdapTools/Resolver/ParameterResolver.php
ParameterResolver.resolve
public function resolve() { if (!empty($this->resolvedParameters)) { return $this->attributes; } $this->evaluateRequirements($this->attributes); $this->resolveAllParameters(); return $this->attributes; }
php
public function resolve() { if (!empty($this->resolvedParameters)) { return $this->attributes; } $this->evaluateRequirements($this->attributes); $this->resolveAllParameters(); return $this->attributes; }
[ "public", "function", "resolve", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "resolvedParameters", ")", ")", "{", "return", "$", "this", "->", "attributes", ";", "}", "$", "this", "->", "evaluateRequirements", "(", "$", "this", "->", "attributes", ")", ";", "$", "this", "->", "resolveAllParameters", "(", ")", ";", "return", "$", "this", "->", "attributes", ";", "}" ]
Gets the attributes with all of the parameters resolved. @return array
[ "Gets", "the", "attributes", "with", "all", "of", "the", "parameters", "resolved", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/ParameterResolver.php#L63-L72
28,059
ldaptools/ldaptools
src/LdapTools/Resolver/ParameterResolver.php
ParameterResolver.resolveAllParameters
protected function resolveAllParameters() { foreach ($this->requirements as $attribute => $parameters) { // This parameter may have already been resolved as part of a dependency if (!in_array($attribute, $this->resolvedParameters)) { $this->resolveParametersForAttribute($attribute, $parameters); } } }
php
protected function resolveAllParameters() { foreach ($this->requirements as $attribute => $parameters) { // This parameter may have already been resolved as part of a dependency if (!in_array($attribute, $this->resolvedParameters)) { $this->resolveParametersForAttribute($attribute, $parameters); } } }
[ "protected", "function", "resolveAllParameters", "(", ")", "{", "foreach", "(", "$", "this", "->", "requirements", "as", "$", "attribute", "=>", "$", "parameters", ")", "{", "// This parameter may have already been resolved as part of a dependency", "if", "(", "!", "in_array", "(", "$", "attribute", ",", "$", "this", "->", "resolvedParameters", ")", ")", "{", "$", "this", "->", "resolveParametersForAttribute", "(", "$", "attribute", ",", "$", "parameters", ")", ";", "}", "}", "}" ]
Iterates over each requirement to resolve the parameters it contains.
[ "Iterates", "over", "each", "requirement", "to", "resolve", "the", "parameters", "it", "contains", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/ParameterResolver.php#L88-L96
28,060
ldaptools/ldaptools
src/LdapTools/Resolver/ParameterResolver.php
ParameterResolver.resolveParametersForAttribute
protected function resolveParametersForAttribute($attribute, array $parameters) { $children = $this->getDependentAttributes($parameters); if (!empty($children)) { foreach ($children as $child) { $this->resolveParametersForAttribute($child, $this->requirements[$child]); } } $this->doResolveParametersForAttribute($attribute, $parameters); $remainingParameters = self::getParametersInValue($this->attributes[$attribute]); // A second pass may be required for attributes it depended on that contained parameters not based on attributes if (!empty($remainingParameters)) { $this->doResolveParametersForAttribute($attribute, $remainingParameters); } $this->resolvedParameters[] = $attribute; }
php
protected function resolveParametersForAttribute($attribute, array $parameters) { $children = $this->getDependentAttributes($parameters); if (!empty($children)) { foreach ($children as $child) { $this->resolveParametersForAttribute($child, $this->requirements[$child]); } } $this->doResolveParametersForAttribute($attribute, $parameters); $remainingParameters = self::getParametersInValue($this->attributes[$attribute]); // A second pass may be required for attributes it depended on that contained parameters not based on attributes if (!empty($remainingParameters)) { $this->doResolveParametersForAttribute($attribute, $remainingParameters); } $this->resolvedParameters[] = $attribute; }
[ "protected", "function", "resolveParametersForAttribute", "(", "$", "attribute", ",", "array", "$", "parameters", ")", "{", "$", "children", "=", "$", "this", "->", "getDependentAttributes", "(", "$", "parameters", ")", ";", "if", "(", "!", "empty", "(", "$", "children", ")", ")", "{", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "this", "->", "resolveParametersForAttribute", "(", "$", "child", ",", "$", "this", "->", "requirements", "[", "$", "child", "]", ")", ";", "}", "}", "$", "this", "->", "doResolveParametersForAttribute", "(", "$", "attribute", ",", "$", "parameters", ")", ";", "$", "remainingParameters", "=", "self", "::", "getParametersInValue", "(", "$", "this", "->", "attributes", "[", "$", "attribute", "]", ")", ";", "// A second pass may be required for attributes it depended on that contained parameters not based on attributes", "if", "(", "!", "empty", "(", "$", "remainingParameters", ")", ")", "{", "$", "this", "->", "doResolveParametersForAttribute", "(", "$", "attribute", ",", "$", "remainingParameters", ")", ";", "}", "$", "this", "->", "resolvedParameters", "[", "]", "=", "$", "attribute", ";", "}" ]
Given a specific attribute with parameters, this will resolve it while first resolving any dependent attributes that first need to be resolved. @param $attribute @param array $parameters
[ "Given", "a", "specific", "attribute", "with", "parameters", "this", "will", "resolve", "it", "while", "first", "resolving", "any", "dependent", "attributes", "that", "first", "need", "to", "be", "resolved", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/ParameterResolver.php#L105-L124
28,061
ldaptools/ldaptools
src/LdapTools/Resolver/ParameterResolver.php
ParameterResolver.doResolveParametersForAttribute
protected function doResolveParametersForAttribute($attribute, $parameters) { $this->attributes[$attribute] = $this->getValueForParameters( $parameters, $this->attributes[$attribute], $this->attributes ); }
php
protected function doResolveParametersForAttribute($attribute, $parameters) { $this->attributes[$attribute] = $this->getValueForParameters( $parameters, $this->attributes[$attribute], $this->attributes ); }
[ "protected", "function", "doResolveParametersForAttribute", "(", "$", "attribute", ",", "$", "parameters", ")", "{", "$", "this", "->", "attributes", "[", "$", "attribute", "]", "=", "$", "this", "->", "getValueForParameters", "(", "$", "parameters", ",", "$", "this", "->", "attributes", "[", "$", "attribute", "]", ",", "$", "this", "->", "attributes", ")", ";", "}" ]
Sets the value for an attribute with the specified parameters. @param string $attribute @param array $parameters
[ "Sets", "the", "value", "for", "an", "attribute", "with", "the", "specified", "parameters", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/ParameterResolver.php#L132-L139
28,062
ldaptools/ldaptools
src/LdapTools/Resolver/ParameterResolver.php
ParameterResolver.getDependentAttributes
protected function getDependentAttributes($parameters) { $dependencies = []; foreach ($parameters as $parameter) { if (isset($this->requirements[$parameter]) && !in_array($parameter, $this->resolvedParameters)) { $dependencies[] = $parameter; } } return $dependencies; }
php
protected function getDependentAttributes($parameters) { $dependencies = []; foreach ($parameters as $parameter) { if (isset($this->requirements[$parameter]) && !in_array($parameter, $this->resolvedParameters)) { $dependencies[] = $parameter; } } return $dependencies; }
[ "protected", "function", "getDependentAttributes", "(", "$", "parameters", ")", "{", "$", "dependencies", "=", "[", "]", ";", "foreach", "(", "$", "parameters", "as", "$", "parameter", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "requirements", "[", "$", "parameter", "]", ")", "&&", "!", "in_array", "(", "$", "parameter", ",", "$", "this", "->", "resolvedParameters", ")", ")", "{", "$", "dependencies", "[", "]", "=", "$", "parameter", ";", "}", "}", "return", "$", "dependencies", ";", "}" ]
Checks for required parameter attributes that depend on other parameter attributes. Returns an array of of dependencies. @param array $parameters @return array
[ "Checks", "for", "required", "parameter", "attributes", "that", "depend", "on", "other", "parameter", "attributes", ".", "Returns", "an", "array", "of", "of", "dependencies", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/ParameterResolver.php#L148-L159
28,063
ldaptools/ldaptools
src/LdapTools/Resolver/ParameterResolver.php
ParameterResolver.setRequirementsForAttribute
protected function setRequirementsForAttribute($attribute, array $value) { $parameters = []; foreach ($value as $attrValue) { $parameters = array_filter(array_merge( $parameters, self::getParametersInValue($attrValue) )); } if (!empty($parameters)) { $this->requirements[$attribute] = $parameters; } }
php
protected function setRequirementsForAttribute($attribute, array $value) { $parameters = []; foreach ($value as $attrValue) { $parameters = array_filter(array_merge( $parameters, self::getParametersInValue($attrValue) )); } if (!empty($parameters)) { $this->requirements[$attribute] = $parameters; } }
[ "protected", "function", "setRequirementsForAttribute", "(", "$", "attribute", ",", "array", "$", "value", ")", "{", "$", "parameters", "=", "[", "]", ";", "foreach", "(", "$", "value", "as", "$", "attrValue", ")", "{", "$", "parameters", "=", "array_filter", "(", "array_merge", "(", "$", "parameters", ",", "self", "::", "getParametersInValue", "(", "$", "attrValue", ")", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "parameters", ")", ")", "{", "$", "this", "->", "requirements", "[", "$", "attribute", "]", "=", "$", "parameters", ";", "}", "}" ]
Given an attribute, set what parameters it requires. @param string $attribute @param array $value
[ "Given", "an", "attribute", "set", "what", "parameters", "it", "requires", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/ParameterResolver.php#L185-L199
28,064
ldaptools/ldaptools
src/LdapTools/Resolver/ParameterResolver.php
ParameterResolver.getParametersInValue
protected static function getParametersInValue($value) { $parameters = []; $regex = '/'.self::PARAM_MARKER.'(.*?)'.self::PARAM_MARKER.'/'; $value = is_array($value) ? $value : [$value]; foreach ($value as $attrValue) { if (is_string($attrValue) && preg_match_all($regex, $attrValue, $matches) && isset($matches[1])) { $parameters = array_merge($parameters, $matches[1]); } } return $parameters; }
php
protected static function getParametersInValue($value) { $parameters = []; $regex = '/'.self::PARAM_MARKER.'(.*?)'.self::PARAM_MARKER.'/'; $value = is_array($value) ? $value : [$value]; foreach ($value as $attrValue) { if (is_string($attrValue) && preg_match_all($regex, $attrValue, $matches) && isset($matches[1])) { $parameters = array_merge($parameters, $matches[1]); } } return $parameters; }
[ "protected", "static", "function", "getParametersInValue", "(", "$", "value", ")", "{", "$", "parameters", "=", "[", "]", ";", "$", "regex", "=", "'/'", ".", "self", "::", "PARAM_MARKER", ".", "'(.*?)'", ".", "self", "::", "PARAM_MARKER", ".", "'/'", ";", "$", "value", "=", "is_array", "(", "$", "value", ")", "?", "$", "value", ":", "[", "$", "value", "]", ";", "foreach", "(", "$", "value", "as", "$", "attrValue", ")", "{", "if", "(", "is_string", "(", "$", "attrValue", ")", "&&", "preg_match_all", "(", "$", "regex", ",", "$", "attrValue", ",", "$", "matches", ")", "&&", "isset", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "$", "parameters", "=", "array_merge", "(", "$", "parameters", ",", "$", "matches", "[", "1", "]", ")", ";", "}", "}", "return", "$", "parameters", ";", "}" ]
Given an attribute value get all parameters it expects. @param string|array $value @return array
[ "Given", "an", "attribute", "value", "get", "all", "parameters", "it", "expects", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/ParameterResolver.php#L207-L220
28,065
ldaptools/ldaptools
src/LdapTools/Resolver/ParameterResolver.php
ParameterResolver.checkForCircularDependency
protected function checkForCircularDependency($parent, array $parentParameters) { foreach ($this->requirements as $attribute => $parameters) { if (in_array($parent, $parameters) && in_array($attribute, $parentParameters)) { throw new LogicException(sprintf( 'Circular parameter dependency detected. Parameters "%s" and "%s" depend on each other.', $parent, $attribute )); } } }
php
protected function checkForCircularDependency($parent, array $parentParameters) { foreach ($this->requirements as $attribute => $parameters) { if (in_array($parent, $parameters) && in_array($attribute, $parentParameters)) { throw new LogicException(sprintf( 'Circular parameter dependency detected. Parameters "%s" and "%s" depend on each other.', $parent, $attribute )); } } }
[ "protected", "function", "checkForCircularDependency", "(", "$", "parent", ",", "array", "$", "parentParameters", ")", "{", "foreach", "(", "$", "this", "->", "requirements", "as", "$", "attribute", "=>", "$", "parameters", ")", "{", "if", "(", "in_array", "(", "$", "parent", ",", "$", "parameters", ")", "&&", "in_array", "(", "$", "attribute", ",", "$", "parentParameters", ")", ")", "{", "throw", "new", "LogicException", "(", "sprintf", "(", "'Circular parameter dependency detected. Parameters \"%s\" and \"%s\" depend on each other.'", ",", "$", "parent", ",", "$", "attribute", ")", ")", ";", "}", "}", "}" ]
Given an attribute with parameter dependencies, check if any of them will become circular. @param string $parent @param array $parentParameters
[ "Given", "an", "attribute", "with", "parameter", "dependencies", "check", "if", "any", "of", "them", "will", "become", "circular", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/ParameterResolver.php#L228-L239
28,066
ldaptools/ldaptools
src/LdapTools/Query/LdapQuery.php
LdapQuery.getSingleResult
public function getSingleResult($hydratorType = HydratorFactory::TO_OBJECT) { $result = $this->execute($hydratorType); $count = ($result instanceof LdapObjectCollection) ? $result->count() : count($result); if ($count === 0) { throw new EmptyResultException('LDAP returned no results.'); } elseif ($count > 1) { throw new MultiResultException(sprintf('Expected a single result but LDAP returned %s result(s).', $count)); } return ($result instanceof LdapObjectCollection) ? $result->first() : reset($result); }
php
public function getSingleResult($hydratorType = HydratorFactory::TO_OBJECT) { $result = $this->execute($hydratorType); $count = ($result instanceof LdapObjectCollection) ? $result->count() : count($result); if ($count === 0) { throw new EmptyResultException('LDAP returned no results.'); } elseif ($count > 1) { throw new MultiResultException(sprintf('Expected a single result but LDAP returned %s result(s).', $count)); } return ($result instanceof LdapObjectCollection) ? $result->first() : reset($result); }
[ "public", "function", "getSingleResult", "(", "$", "hydratorType", "=", "HydratorFactory", "::", "TO_OBJECT", ")", "{", "$", "result", "=", "$", "this", "->", "execute", "(", "$", "hydratorType", ")", ";", "$", "count", "=", "(", "$", "result", "instanceof", "LdapObjectCollection", ")", "?", "$", "result", "->", "count", "(", ")", ":", "count", "(", "$", "result", ")", ";", "if", "(", "$", "count", "===", "0", ")", "{", "throw", "new", "EmptyResultException", "(", "'LDAP returned no results.'", ")", ";", "}", "elseif", "(", "$", "count", ">", "1", ")", "{", "throw", "new", "MultiResultException", "(", "sprintf", "(", "'Expected a single result but LDAP returned %s result(s).'", ",", "$", "count", ")", ")", ";", "}", "return", "(", "$", "result", "instanceof", "LdapObjectCollection", ")", "?", "$", "result", "->", "first", "(", ")", ":", "reset", "(", "$", "result", ")", ";", "}" ]
Retrieve a single unique result from LDAP. If the result is empty or contains more than one entry, an exception is thrown. @param string $hydratorType A hyrdrator type constant from the factory. @return array|\LdapTools\Object\LdapObject @throws EmptyResultException @throws MultiResultException
[ "Retrieve", "a", "single", "unique", "result", "from", "LDAP", ".", "If", "the", "result", "is", "empty", "or", "contains", "more", "than", "one", "entry", "an", "exception", "is", "thrown", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/LdapQuery.php#L162-L174
28,067
ldaptools/ldaptools
src/LdapTools/Query/LdapQuery.php
LdapQuery.getSingleScalarResult
public function getSingleScalarResult() { if (count($this->operation->getAttributes()) !== 1 || $this->isWildCardSelection()) { $selected = $this->isWildCardSelection() ? 'All' : count($this->operation->getAttributes()); throw new LdapQueryException(sprintf( 'When retrieving a single value you should only select a single attribute. %s are selected.', $selected )); } $attribute = $this->operation->getAttributes(); $attribute = reset($attribute); $result = $this->getSingleResult(); if (!$result->has($attribute)) { throw new AttributeNotFoundException(sprintf('Attribute "%s" not found for this LDAP object.', $attribute)); } return $result->get($attribute); }
php
public function getSingleScalarResult() { if (count($this->operation->getAttributes()) !== 1 || $this->isWildCardSelection()) { $selected = $this->isWildCardSelection() ? 'All' : count($this->operation->getAttributes()); throw new LdapQueryException(sprintf( 'When retrieving a single value you should only select a single attribute. %s are selected.', $selected )); } $attribute = $this->operation->getAttributes(); $attribute = reset($attribute); $result = $this->getSingleResult(); if (!$result->has($attribute)) { throw new AttributeNotFoundException(sprintf('Attribute "%s" not found for this LDAP object.', $attribute)); } return $result->get($attribute); }
[ "public", "function", "getSingleScalarResult", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "operation", "->", "getAttributes", "(", ")", ")", "!==", "1", "||", "$", "this", "->", "isWildCardSelection", "(", ")", ")", "{", "$", "selected", "=", "$", "this", "->", "isWildCardSelection", "(", ")", "?", "'All'", ":", "count", "(", "$", "this", "->", "operation", "->", "getAttributes", "(", ")", ")", ";", "throw", "new", "LdapQueryException", "(", "sprintf", "(", "'When retrieving a single value you should only select a single attribute. %s are selected.'", ",", "$", "selected", ")", ")", ";", "}", "$", "attribute", "=", "$", "this", "->", "operation", "->", "getAttributes", "(", ")", ";", "$", "attribute", "=", "reset", "(", "$", "attribute", ")", ";", "$", "result", "=", "$", "this", "->", "getSingleResult", "(", ")", ";", "if", "(", "!", "$", "result", "->", "has", "(", "$", "attribute", ")", ")", "{", "throw", "new", "AttributeNotFoundException", "(", "sprintf", "(", "'Attribute \"%s\" not found for this LDAP object.'", ",", "$", "attribute", ")", ")", ";", "}", "return", "$", "result", "->", "get", "(", "$", "attribute", ")", ";", "}" ]
Retrieve a single selected attribute value from LDAP. @return mixed @throws LdapQueryException @throws AttributeNotFoundException @throws EmptyResultException @throws MultiResultException
[ "Retrieve", "a", "single", "selected", "attribute", "value", "from", "LDAP", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/LdapQuery.php#L185-L203
28,068
ldaptools/ldaptools
src/LdapTools/Query/LdapQuery.php
LdapQuery.execute
public function execute($hydratorType = HydratorFactory::TO_OBJECT) { if (is_string($this->operation->getFilter()) || empty($this->operation->getFilter()->getAliases())) { $results = $this->getResultsFromLdap(clone $this->operation, $hydratorType); } else { $results = $this->getResultsForAliases($hydratorType); } return $this->sortResults($results); }
php
public function execute($hydratorType = HydratorFactory::TO_OBJECT) { if (is_string($this->operation->getFilter()) || empty($this->operation->getFilter()->getAliases())) { $results = $this->getResultsFromLdap(clone $this->operation, $hydratorType); } else { $results = $this->getResultsForAliases($hydratorType); } return $this->sortResults($results); }
[ "public", "function", "execute", "(", "$", "hydratorType", "=", "HydratorFactory", "::", "TO_OBJECT", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "operation", "->", "getFilter", "(", ")", ")", "||", "empty", "(", "$", "this", "->", "operation", "->", "getFilter", "(", ")", "->", "getAliases", "(", ")", ")", ")", "{", "$", "results", "=", "$", "this", "->", "getResultsFromLdap", "(", "clone", "$", "this", "->", "operation", ",", "$", "hydratorType", ")", ";", "}", "else", "{", "$", "results", "=", "$", "this", "->", "getResultsForAliases", "(", "$", "hydratorType", ")", ";", "}", "return", "$", "this", "->", "sortResults", "(", "$", "results", ")", ";", "}" ]
Execute a query based on the set parameters. Optionally choose a mode to hydrate the results in. @param string $hydratorType A hyrdrator type constant from the factory. @return mixed|\LdapTools\Object\LdapObject|\LdapTools\Object\LdapObjectCollection
[ "Execute", "a", "query", "based", "on", "the", "set", "parameters", ".", "Optionally", "choose", "a", "mode", "to", "hydrate", "the", "results", "in", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/LdapQuery.php#L251-L260
28,069
ldaptools/ldaptools
src/LdapTools/Query/LdapQuery.php
LdapQuery.setOrderBy
public function setOrderBy(array $orderBy) { // Validate and force the case for the direction. foreach ($orderBy as $attribute => $direction) { if (!in_array(strtoupper($direction), self::ORDER)) { throw new \InvalidArgumentException(sprintf( 'Order direction "%s" is invalid. Valid values are ASC and DESC', $direction )); } $orderBy[$attribute] = strtoupper($direction); } $this->orderBy = $orderBy; return $this; }
php
public function setOrderBy(array $orderBy) { // Validate and force the case for the direction. foreach ($orderBy as $attribute => $direction) { if (!in_array(strtoupper($direction), self::ORDER)) { throw new \InvalidArgumentException(sprintf( 'Order direction "%s" is invalid. Valid values are ASC and DESC', $direction )); } $orderBy[$attribute] = strtoupper($direction); } $this->orderBy = $orderBy; return $this; }
[ "public", "function", "setOrderBy", "(", "array", "$", "orderBy", ")", "{", "// Validate and force the case for the direction.", "foreach", "(", "$", "orderBy", "as", "$", "attribute", "=>", "$", "direction", ")", "{", "if", "(", "!", "in_array", "(", "strtoupper", "(", "$", "direction", ")", ",", "self", "::", "ORDER", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Order direction \"%s\" is invalid. Valid values are ASC and DESC'", ",", "$", "direction", ")", ")", ";", "}", "$", "orderBy", "[", "$", "attribute", "]", "=", "strtoupper", "(", "$", "direction", ")", ";", "}", "$", "this", "->", "orderBy", "=", "$", "orderBy", ";", "return", "$", "this", ";", "}" ]
Set the attributes to order the results by. @param array $orderBy In the form of ['attribute' => 'ASC', ...] @return $this
[ "Set", "the", "attributes", "to", "order", "the", "results", "by", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/LdapQuery.php#L291-L306
28,070
ldaptools/ldaptools
src/LdapTools/Query/LdapQuery.php
LdapQuery.getResultsForAliases
protected function getResultsForAliases($hydratorType) { /** @var LdapObjectCollection|array $results */ $results = []; foreach ($this->operation->getFilter()->getAliases() as $alias => $schema) { $operation = clone $this->operation; /** * If we received the partial limit of results, re-adjust the next operations limit so we don't go over. * * @todo This is getting difficult due to multiple operations needed to select all schema types. If this was * a single operation the issue would not exist. But with a single query and multiple types I cannot * easily determine which result is what type. Unsure of the best way to fix this at the moment. */ if ($operation->getSizeLimit() && count($results) < $operation->getSizeLimit()) { $operation->setSizeLimit($operation->getSizeLimit() - count($results)); } $objects = $this->getResultsFromLdap($operation, $hydratorType, $schema, $alias); if ($objects instanceof LdapObjectCollection && $results) { $results->add(...$objects->toArray()); } elseif ($objects instanceof LdapObjectCollection) { $results = $objects; } else { $results = array_merge($results, $objects); } // If the results have reached the expected size limit then end the loop. if ($this->operation->getSizeLimit() && count($results) == $operation->getSizeLimit()) { break; } } return $results; }
php
protected function getResultsForAliases($hydratorType) { /** @var LdapObjectCollection|array $results */ $results = []; foreach ($this->operation->getFilter()->getAliases() as $alias => $schema) { $operation = clone $this->operation; /** * If we received the partial limit of results, re-adjust the next operations limit so we don't go over. * * @todo This is getting difficult due to multiple operations needed to select all schema types. If this was * a single operation the issue would not exist. But with a single query and multiple types I cannot * easily determine which result is what type. Unsure of the best way to fix this at the moment. */ if ($operation->getSizeLimit() && count($results) < $operation->getSizeLimit()) { $operation->setSizeLimit($operation->getSizeLimit() - count($results)); } $objects = $this->getResultsFromLdap($operation, $hydratorType, $schema, $alias); if ($objects instanceof LdapObjectCollection && $results) { $results->add(...$objects->toArray()); } elseif ($objects instanceof LdapObjectCollection) { $results = $objects; } else { $results = array_merge($results, $objects); } // If the results have reached the expected size limit then end the loop. if ($this->operation->getSizeLimit() && count($results) == $operation->getSizeLimit()) { break; } } return $results; }
[ "protected", "function", "getResultsForAliases", "(", "$", "hydratorType", ")", "{", "/** @var LdapObjectCollection|array $results */", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "operation", "->", "getFilter", "(", ")", "->", "getAliases", "(", ")", "as", "$", "alias", "=>", "$", "schema", ")", "{", "$", "operation", "=", "clone", "$", "this", "->", "operation", ";", "/**\n * If we received the partial limit of results, re-adjust the next operations limit so we don't go over.\n *\n * @todo This is getting difficult due to multiple operations needed to select all schema types. If this was\n * a single operation the issue would not exist. But with a single query and multiple types I cannot\n * easily determine which result is what type. Unsure of the best way to fix this at the moment.\n */", "if", "(", "$", "operation", "->", "getSizeLimit", "(", ")", "&&", "count", "(", "$", "results", ")", "<", "$", "operation", "->", "getSizeLimit", "(", ")", ")", "{", "$", "operation", "->", "setSizeLimit", "(", "$", "operation", "->", "getSizeLimit", "(", ")", "-", "count", "(", "$", "results", ")", ")", ";", "}", "$", "objects", "=", "$", "this", "->", "getResultsFromLdap", "(", "$", "operation", ",", "$", "hydratorType", ",", "$", "schema", ",", "$", "alias", ")", ";", "if", "(", "$", "objects", "instanceof", "LdapObjectCollection", "&&", "$", "results", ")", "{", "$", "results", "->", "add", "(", "...", "$", "objects", "->", "toArray", "(", ")", ")", ";", "}", "elseif", "(", "$", "objects", "instanceof", "LdapObjectCollection", ")", "{", "$", "results", "=", "$", "objects", ";", "}", "else", "{", "$", "results", "=", "array_merge", "(", "$", "results", ",", "$", "objects", ")", ";", "}", "// If the results have reached the expected size limit then end the loop.", "if", "(", "$", "this", "->", "operation", "->", "getSizeLimit", "(", ")", "&&", "count", "(", "$", "results", ")", "==", "$", "operation", "->", "getSizeLimit", "(", ")", ")", "{", "break", ";", "}", "}", "return", "$", "results", ";", "}" ]
Goes through each alias for the operation to get results only for that specific type, then combine and return them all. @param string $hydratorType @return array|LdapObjectCollection|mixed
[ "Goes", "through", "each", "alias", "for", "the", "operation", "to", "get", "results", "only", "for", "that", "specific", "type", "then", "combine", "and", "return", "them", "all", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/LdapQuery.php#L393-L428
28,071
ldaptools/ldaptools
src/LdapTools/Query/LdapQuery.php
LdapQuery.getSelectedForAllAliases
protected function getSelectedForAllAliases(array $aliases) { if (empty($aliases)) { $selected = $this->mergeOrderByAttributes($this->getSelectedQueryAttributes($this->operation->getAttributes())); } else { // If there are aliases, then we need to loop through each one to determine was was actually selected for each. $selected = []; foreach ($aliases as $alias => $schema) { $selected = array_replace( $selected, $this->mergeOrderByAttributes($this->getSelectedQueryAttributes($this->operation->getAttributes(), $schema), $alias) ); } } return $selected; }
php
protected function getSelectedForAllAliases(array $aliases) { if (empty($aliases)) { $selected = $this->mergeOrderByAttributes($this->getSelectedQueryAttributes($this->operation->getAttributes())); } else { // If there are aliases, then we need to loop through each one to determine was was actually selected for each. $selected = []; foreach ($aliases as $alias => $schema) { $selected = array_replace( $selected, $this->mergeOrderByAttributes($this->getSelectedQueryAttributes($this->operation->getAttributes(), $schema), $alias) ); } } return $selected; }
[ "protected", "function", "getSelectedForAllAliases", "(", "array", "$", "aliases", ")", "{", "if", "(", "empty", "(", "$", "aliases", ")", ")", "{", "$", "selected", "=", "$", "this", "->", "mergeOrderByAttributes", "(", "$", "this", "->", "getSelectedQueryAttributes", "(", "$", "this", "->", "operation", "->", "getAttributes", "(", ")", ")", ")", ";", "}", "else", "{", "// If there are aliases, then we need to loop through each one to determine was was actually selected for each.", "$", "selected", "=", "[", "]", ";", "foreach", "(", "$", "aliases", "as", "$", "alias", "=>", "$", "schema", ")", "{", "$", "selected", "=", "array_replace", "(", "$", "selected", ",", "$", "this", "->", "mergeOrderByAttributes", "(", "$", "this", "->", "getSelectedQueryAttributes", "(", "$", "this", "->", "operation", "->", "getAttributes", "(", ")", ",", "$", "schema", ")", ",", "$", "alias", ")", ")", ";", "}", "}", "return", "$", "selected", ";", "}" ]
Get all the attributes that were selected for the query taking into account all of the aliases used. @param array $aliases @return array
[ "Get", "all", "the", "attributes", "that", "were", "selected", "for", "the", "query", "taking", "into", "account", "all", "of", "the", "aliases", "used", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/LdapQuery.php#L436-L452
28,072
ldaptools/ldaptools
src/LdapTools/Query/LdapQuery.php
LdapQuery.getFormattedOrderBy
protected function getFormattedOrderBy($selected, $aliases) { if (!empty($aliases) && !$this->isWildCardSelection()) { $orderBy = []; foreach ($this->orderBy as $attribute => $direction) { list($alias, $attr) = LdapUtilities::getAliasAndAttribute($attribute); $orderAttr = AttributeNameResolver::arraySearchGetValue($attr, $selected); $orderAttr = $alias ? "$alias.$orderAttr" : $orderAttr; $orderBy[$orderAttr] = $direction; } } else { $orderBy = $this->orderBy; } return $orderBy; }
php
protected function getFormattedOrderBy($selected, $aliases) { if (!empty($aliases) && !$this->isWildCardSelection()) { $orderBy = []; foreach ($this->orderBy as $attribute => $direction) { list($alias, $attr) = LdapUtilities::getAliasAndAttribute($attribute); $orderAttr = AttributeNameResolver::arraySearchGetValue($attr, $selected); $orderAttr = $alias ? "$alias.$orderAttr" : $orderAttr; $orderBy[$orderAttr] = $direction; } } else { $orderBy = $this->orderBy; } return $orderBy; }
[ "protected", "function", "getFormattedOrderBy", "(", "$", "selected", ",", "$", "aliases", ")", "{", "if", "(", "!", "empty", "(", "$", "aliases", ")", "&&", "!", "$", "this", "->", "isWildCardSelection", "(", ")", ")", "{", "$", "orderBy", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "orderBy", "as", "$", "attribute", "=>", "$", "direction", ")", "{", "list", "(", "$", "alias", ",", "$", "attr", ")", "=", "LdapUtilities", "::", "getAliasAndAttribute", "(", "$", "attribute", ")", ";", "$", "orderAttr", "=", "AttributeNameResolver", "::", "arraySearchGetValue", "(", "$", "attr", ",", "$", "selected", ")", ";", "$", "orderAttr", "=", "$", "alias", "?", "\"$alias.$orderAttr\"", ":", "$", "orderAttr", ";", "$", "orderBy", "[", "$", "orderAttr", "]", "=", "$", "direction", ";", "}", "}", "else", "{", "$", "orderBy", "=", "$", "this", "->", "orderBy", ";", "}", "return", "$", "orderBy", ";", "}" ]
This formats the orderBy array to ignore case differences between the orderBy name and the actually selected name, such as for sorting arrays. @param $selected @param $aliases @return array
[ "This", "formats", "the", "orderBy", "array", "to", "ignore", "case", "differences", "between", "the", "orderBy", "name", "and", "the", "actually", "selected", "name", "such", "as", "for", "sorting", "arrays", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/LdapQuery.php#L462-L477
28,073
ldaptools/ldaptools
src/LdapTools/Factory/LdapObjectSchemaFactory.php
LdapObjectSchemaFactory.get
public function get($schemaName, $objectType) { $key = CacheItem::TYPE['SCHEMA_OBJECT'].'.'.$schemaName.'.'.$objectType; if ($this->shouldBuildCacheItem($key, $schemaName)) { $ldapObjectSchema = $this->parser->parse($schemaName, $objectType); $this->dispatcher->dispatch(new LdapObjectSchemaEvent(Event::LDAP_SCHEMA_LOAD, $ldapObjectSchema)); $this->cache->set(new CacheItem($key, $ldapObjectSchema)); } else { $ldapObjectSchema = $this->cache->get($key)->getValue(); } return $ldapObjectSchema; }
php
public function get($schemaName, $objectType) { $key = CacheItem::TYPE['SCHEMA_OBJECT'].'.'.$schemaName.'.'.$objectType; if ($this->shouldBuildCacheItem($key, $schemaName)) { $ldapObjectSchema = $this->parser->parse($schemaName, $objectType); $this->dispatcher->dispatch(new LdapObjectSchemaEvent(Event::LDAP_SCHEMA_LOAD, $ldapObjectSchema)); $this->cache->set(new CacheItem($key, $ldapObjectSchema)); } else { $ldapObjectSchema = $this->cache->get($key)->getValue(); } return $ldapObjectSchema; }
[ "public", "function", "get", "(", "$", "schemaName", ",", "$", "objectType", ")", "{", "$", "key", "=", "CacheItem", "::", "TYPE", "[", "'SCHEMA_OBJECT'", "]", ".", "'.'", ".", "$", "schemaName", ".", "'.'", ".", "$", "objectType", ";", "if", "(", "$", "this", "->", "shouldBuildCacheItem", "(", "$", "key", ",", "$", "schemaName", ")", ")", "{", "$", "ldapObjectSchema", "=", "$", "this", "->", "parser", "->", "parse", "(", "$", "schemaName", ",", "$", "objectType", ")", ";", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "new", "LdapObjectSchemaEvent", "(", "Event", "::", "LDAP_SCHEMA_LOAD", ",", "$", "ldapObjectSchema", ")", ")", ";", "$", "this", "->", "cache", "->", "set", "(", "new", "CacheItem", "(", "$", "key", ",", "$", "ldapObjectSchema", ")", ")", ";", "}", "else", "{", "$", "ldapObjectSchema", "=", "$", "this", "->", "cache", "->", "get", "(", "$", "key", ")", "->", "getValue", "(", ")", ";", "}", "return", "$", "ldapObjectSchema", ";", "}" ]
Get the LdapObjectSchema for a specific schema name and object type. @param string $schemaName @param string $objectType @return LdapObjectSchema
[ "Get", "the", "LdapObjectSchema", "for", "a", "specific", "schema", "name", "and", "object", "type", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Factory/LdapObjectSchemaFactory.php#L62-L75
28,074
ldaptools/ldaptools
src/LdapTools/Factory/LdapObjectSchemaFactory.php
LdapObjectSchemaFactory.shouldBuildCacheItem
protected function shouldBuildCacheItem($key, $schemaName) { $cacheOutOfDate = false; if ($this->cache->getUseAutoCache()) { $lastModTime = $this->parser->getSchemaModificationTime($schemaName); $cacheCreationTime = $this->cache->getCacheCreationTime($key); $cacheOutOfDate = (!$lastModTime || ($lastModTime > $cacheCreationTime)); } return ($cacheOutOfDate || !$this->cache->contains($key)); }
php
protected function shouldBuildCacheItem($key, $schemaName) { $cacheOutOfDate = false; if ($this->cache->getUseAutoCache()) { $lastModTime = $this->parser->getSchemaModificationTime($schemaName); $cacheCreationTime = $this->cache->getCacheCreationTime($key); $cacheOutOfDate = (!$lastModTime || ($lastModTime > $cacheCreationTime)); } return ($cacheOutOfDate || !$this->cache->contains($key)); }
[ "protected", "function", "shouldBuildCacheItem", "(", "$", "key", ",", "$", "schemaName", ")", "{", "$", "cacheOutOfDate", "=", "false", ";", "if", "(", "$", "this", "->", "cache", "->", "getUseAutoCache", "(", ")", ")", "{", "$", "lastModTime", "=", "$", "this", "->", "parser", "->", "getSchemaModificationTime", "(", "$", "schemaName", ")", ";", "$", "cacheCreationTime", "=", "$", "this", "->", "cache", "->", "getCacheCreationTime", "(", "$", "key", ")", ";", "$", "cacheOutOfDate", "=", "(", "!", "$", "lastModTime", "||", "(", "$", "lastModTime", ">", "$", "cacheCreationTime", ")", ")", ";", "}", "return", "(", "$", "cacheOutOfDate", "||", "!", "$", "this", "->", "cache", "->", "contains", "(", "$", "key", ")", ")", ";", "}" ]
Whether or not the item needs to be parsed and cached. @param string $key The cache key. @param string $schemaName The schema name. @return bool
[ "Whether", "or", "not", "the", "item", "needs", "to", "be", "parsed", "and", "cached", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Factory/LdapObjectSchemaFactory.php#L84-L94
28,075
ldaptools/ldaptools
src/LdapTools/Connection/LdapControl.php
LdapControl.toArray
public function toArray() { $control = [ 'oid' => $this->resolveOid(), 'iscritical' => $this->criticality ]; if (!is_null($this->value)) { $control['value'] = $this->value; } return $control; }
php
public function toArray() { $control = [ 'oid' => $this->resolveOid(), 'iscritical' => $this->criticality ]; if (!is_null($this->value)) { $control['value'] = $this->value; } return $control; }
[ "public", "function", "toArray", "(", ")", "{", "$", "control", "=", "[", "'oid'", "=>", "$", "this", "->", "resolveOid", "(", ")", ",", "'iscritical'", "=>", "$", "this", "->", "criticality", "]", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "value", ")", ")", "{", "$", "control", "[", "'value'", "]", "=", "$", "this", "->", "value", ";", "}", "return", "$", "control", ";", "}" ]
Get the control array structure that ldap_set_option expects. @return array
[ "Get", "the", "control", "array", "structure", "that", "ldap_set_option", "expects", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/LdapControl.php#L153-L164
28,076
ldaptools/ldaptools
src/LdapTools/Hydrator/ArrayHydrator.php
ArrayHydrator.setAttributeFromLdap
protected function setAttributeFromLdap(array $entry, $attribute, $value) { if (isset($value['count']) && $value['count'] == 1) { $entry[$attribute] = $value[0]; } elseif (isset($value['count']) && $value['count'] > 0) { $entry[$attribute] = []; for ($i = 0; $i < $value['count']; $i++) { $entry[$attribute][] = $value[$i]; } } elseif ($attribute === 'dn') { $entry[$attribute] = $value; } return $entry; }
php
protected function setAttributeFromLdap(array $entry, $attribute, $value) { if (isset($value['count']) && $value['count'] == 1) { $entry[$attribute] = $value[0]; } elseif (isset($value['count']) && $value['count'] > 0) { $entry[$attribute] = []; for ($i = 0; $i < $value['count']; $i++) { $entry[$attribute][] = $value[$i]; } } elseif ($attribute === 'dn') { $entry[$attribute] = $value; } return $entry; }
[ "protected", "function", "setAttributeFromLdap", "(", "array", "$", "entry", ",", "$", "attribute", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "value", "[", "'count'", "]", ")", "&&", "$", "value", "[", "'count'", "]", "==", "1", ")", "{", "$", "entry", "[", "$", "attribute", "]", "=", "$", "value", "[", "0", "]", ";", "}", "elseif", "(", "isset", "(", "$", "value", "[", "'count'", "]", ")", "&&", "$", "value", "[", "'count'", "]", ">", "0", ")", "{", "$", "entry", "[", "$", "attribute", "]", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "value", "[", "'count'", "]", ";", "$", "i", "++", ")", "{", "$", "entry", "[", "$", "attribute", "]", "[", "]", "=", "$", "value", "[", "$", "i", "]", ";", "}", "}", "elseif", "(", "$", "attribute", "===", "'dn'", ")", "{", "$", "entry", "[", "$", "attribute", "]", "=", "$", "value", ";", "}", "return", "$", "entry", ";", "}" ]
Given a specific attribute and value add it to the newly formed LDAP entry array. @param array $entry @param string $attribute @param string|array $value @return array
[ "Given", "a", "specific", "attribute", "and", "value", "add", "it", "to", "the", "newly", "formed", "LDAP", "entry", "array", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/ArrayHydrator.php#L204-L218
28,077
ldaptools/ldaptools
src/LdapTools/Hydrator/ArrayHydrator.php
ArrayHydrator.convertValuesFromLdap
protected function convertValuesFromLdap(array $entry) { if (!$this->schema) { return $entry; } $valueResolver = BaseValueResolver::getInstance( $this->schema, $entry, $this->type ); $this->configureValueResolver($valueResolver, isset($entry['dn']) ? $entry['dn'] : null); return $valueResolver->fromLdap(); }
php
protected function convertValuesFromLdap(array $entry) { if (!$this->schema) { return $entry; } $valueResolver = BaseValueResolver::getInstance( $this->schema, $entry, $this->type ); $this->configureValueResolver($valueResolver, isset($entry['dn']) ? $entry['dn'] : null); return $valueResolver->fromLdap(); }
[ "protected", "function", "convertValuesFromLdap", "(", "array", "$", "entry", ")", "{", "if", "(", "!", "$", "this", "->", "schema", ")", "{", "return", "$", "entry", ";", "}", "$", "valueResolver", "=", "BaseValueResolver", "::", "getInstance", "(", "$", "this", "->", "schema", ",", "$", "entry", ",", "$", "this", "->", "type", ")", ";", "$", "this", "->", "configureValueResolver", "(", "$", "valueResolver", ",", "isset", "(", "$", "entry", "[", "'dn'", "]", ")", "?", "$", "entry", "[", "'dn'", "]", ":", "null", ")", ";", "return", "$", "valueResolver", "->", "fromLdap", "(", ")", ";", "}" ]
Replace attribute values with the converted values if the attribute has a converter defined. @param array $entry @return array
[ "Replace", "attribute", "values", "with", "the", "converted", "values", "if", "the", "attribute", "has", "a", "converter", "defined", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/ArrayHydrator.php#L237-L250
28,078
ldaptools/ldaptools
src/LdapTools/Hydrator/ArrayHydrator.php
ArrayHydrator.mergeDefaultAttributes
protected function mergeDefaultAttributes(array $attributes) { if ($this->schema && !empty($this->schema->getDefaultValues())) { $attributes = array_merge($this->schema->getDefaultValues(), $attributes); } return $attributes; }
php
protected function mergeDefaultAttributes(array $attributes) { if ($this->schema && !empty($this->schema->getDefaultValues())) { $attributes = array_merge($this->schema->getDefaultValues(), $attributes); } return $attributes; }
[ "protected", "function", "mergeDefaultAttributes", "(", "array", "$", "attributes", ")", "{", "if", "(", "$", "this", "->", "schema", "&&", "!", "empty", "(", "$", "this", "->", "schema", "->", "getDefaultValues", "(", ")", ")", ")", "{", "$", "attributes", "=", "array_merge", "(", "$", "this", "->", "schema", "->", "getDefaultValues", "(", ")", ",", "$", "attributes", ")", ";", "}", "return", "$", "attributes", ";", "}" ]
Returns all of the attributes to be sent to LDAP after factoring in possible default schema values. @param array $attributes @return array
[ "Returns", "all", "of", "the", "attributes", "to", "be", "sent", "to", "LDAP", "after", "factoring", "in", "possible", "default", "schema", "values", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/ArrayHydrator.php#L258-L265
28,079
ldaptools/ldaptools
src/LdapTools/Hydrator/ArrayHydrator.php
ArrayHydrator.validateAttributesToLdap
protected function validateAttributesToLdap(array $attributes) { if (!$this->schema) { return; } $missing = []; foreach ($this->schema->getRequiredAttributes() as $attribute) { if (!array_key_exists(strtolower($attribute), array_change_key_case($attributes))) { $missing[] = $attribute; } } if (!empty($missing)) { throw new LogicException( sprintf('The following required attributes are missing: %s', implode(', ', $missing)) ); } }
php
protected function validateAttributesToLdap(array $attributes) { if (!$this->schema) { return; } $missing = []; foreach ($this->schema->getRequiredAttributes() as $attribute) { if (!array_key_exists(strtolower($attribute), array_change_key_case($attributes))) { $missing[] = $attribute; } } if (!empty($missing)) { throw new LogicException( sprintf('The following required attributes are missing: %s', implode(', ', $missing)) ); } }
[ "protected", "function", "validateAttributesToLdap", "(", "array", "$", "attributes", ")", "{", "if", "(", "!", "$", "this", "->", "schema", ")", "{", "return", ";", "}", "$", "missing", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "schema", "->", "getRequiredAttributes", "(", ")", "as", "$", "attribute", ")", "{", "if", "(", "!", "array_key_exists", "(", "strtolower", "(", "$", "attribute", ")", ",", "array_change_key_case", "(", "$", "attributes", ")", ")", ")", "{", "$", "missing", "[", "]", "=", "$", "attribute", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "missing", ")", ")", "{", "throw", "new", "LogicException", "(", "sprintf", "(", "'The following required attributes are missing: %s'", ",", "implode", "(", "', '", ",", "$", "missing", ")", ")", ")", ";", "}", "}" ]
Checks to make sure all required attributes are present. @param array $attributes
[ "Checks", "to", "make", "sure", "all", "required", "attributes", "are", "present", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/ArrayHydrator.php#L273-L291
28,080
ldaptools/ldaptools
src/LdapTools/Hydrator/ArrayHydrator.php
ArrayHydrator.convertValuesToLdap
protected function convertValuesToLdap($values, $dn = null) { if (!($values instanceof OperatorCollection) && !$this->schema) { return $values; } $valueResolver = BaseValueResolver::getInstance( $this->schema, $values, $this->type ); $this->configureValueResolver($valueResolver, $dn); return $valueResolver->toLdap(); }
php
protected function convertValuesToLdap($values, $dn = null) { if (!($values instanceof OperatorCollection) && !$this->schema) { return $values; } $valueResolver = BaseValueResolver::getInstance( $this->schema, $values, $this->type ); $this->configureValueResolver($valueResolver, $dn); return $valueResolver->toLdap(); }
[ "protected", "function", "convertValuesToLdap", "(", "$", "values", ",", "$", "dn", "=", "null", ")", "{", "if", "(", "!", "(", "$", "values", "instanceof", "OperatorCollection", ")", "&&", "!", "$", "this", "->", "schema", ")", "{", "return", "$", "values", ";", "}", "$", "valueResolver", "=", "BaseValueResolver", "::", "getInstance", "(", "$", "this", "->", "schema", ",", "$", "values", ",", "$", "this", "->", "type", ")", ";", "$", "this", "->", "configureValueResolver", "(", "$", "valueResolver", ",", "$", "dn", ")", ";", "return", "$", "valueResolver", "->", "toLdap", "(", ")", ";", "}" ]
Checks for attributes assigned an attribute converter. It will replace the value with the converted value then send back all the attributes. @param array|BatchCollection|OperatorCollection $values @param string|null $dn @return array|BatchCollection|OperatorCollection
[ "Checks", "for", "attributes", "assigned", "an", "attribute", "converter", ".", "It", "will", "replace", "the", "value", "with", "the", "converted", "value", "then", "send", "back", "all", "the", "attributes", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/ArrayHydrator.php#L301-L314
28,081
ldaptools/ldaptools
src/LdapTools/Hydrator/ArrayHydrator.php
ArrayHydrator.convertNamesToLdap
protected function convertNamesToLdap(array $attributes) { return !$this->schema ? $attributes : (new AttributeNameResolver($this->schema))->toLdap($attributes); }
php
protected function convertNamesToLdap(array $attributes) { return !$this->schema ? $attributes : (new AttributeNameResolver($this->schema))->toLdap($attributes); }
[ "protected", "function", "convertNamesToLdap", "(", "array", "$", "attributes", ")", "{", "return", "!", "$", "this", "->", "schema", "?", "$", "attributes", ":", "(", "new", "AttributeNameResolver", "(", "$", "this", "->", "schema", ")", ")", "->", "toLdap", "(", "$", "attributes", ")", ";", "}" ]
Converts attribute names from their schema defined value to the value LDAP needs them in. @param array $attributes @return array
[ "Converts", "attribute", "names", "from", "their", "schema", "defined", "value", "to", "the", "value", "LDAP", "needs", "them", "in", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/ArrayHydrator.php#L322-L325
28,082
ldaptools/ldaptools
src/LdapTools/Hydrator/ArrayHydrator.php
ArrayHydrator.configureValueResolver
protected function configureValueResolver(BaseValueResolver $valueResolver, $dn = null) { if ($this->connection) { $valueResolver->setLdapConnection($this->connection); } if (!is_null($dn)) { $valueResolver->setDn($dn); } }
php
protected function configureValueResolver(BaseValueResolver $valueResolver, $dn = null) { if ($this->connection) { $valueResolver->setLdapConnection($this->connection); } if (!is_null($dn)) { $valueResolver->setDn($dn); } }
[ "protected", "function", "configureValueResolver", "(", "BaseValueResolver", "$", "valueResolver", ",", "$", "dn", "=", "null", ")", "{", "if", "(", "$", "this", "->", "connection", ")", "{", "$", "valueResolver", "->", "setLdapConnection", "(", "$", "this", "->", "connection", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "dn", ")", ")", "{", "$", "valueResolver", "->", "setDn", "(", "$", "dn", ")", ";", "}", "}" ]
Retrieve the AttributeValueResolver instance with the connection and other information set if needed. @param BaseValueResolver $valueResolver @param null|string $dn
[ "Retrieve", "the", "AttributeValueResolver", "instance", "with", "the", "connection", "and", "other", "information", "set", "if", "needed", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/ArrayHydrator.php#L344-L352
28,083
ldaptools/ldaptools
src/LdapTools/Resolver/AttributeValueResolver.php
AttributeValueResolver.fromLdap
public function fromLdap() { $entry = $this->convert($this->entry, false); foreach ($entry as $attribute => $value) { if ($this->schema->isMultivaluedAttribute($attribute) && !is_array($value)) { $entry[$attribute] = [$value]; } } return $entry; }
php
public function fromLdap() { $entry = $this->convert($this->entry, false); foreach ($entry as $attribute => $value) { if ($this->schema->isMultivaluedAttribute($attribute) && !is_array($value)) { $entry[$attribute] = [$value]; } } return $entry; }
[ "public", "function", "fromLdap", "(", ")", "{", "$", "entry", "=", "$", "this", "->", "convert", "(", "$", "this", "->", "entry", ",", "false", ")", ";", "foreach", "(", "$", "entry", "as", "$", "attribute", "=>", "$", "value", ")", "{", "if", "(", "$", "this", "->", "schema", "->", "isMultivaluedAttribute", "(", "$", "attribute", ")", "&&", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "entry", "[", "$", "attribute", "]", "=", "[", "$", "value", "]", ";", "}", "}", "return", "$", "entry", ";", "}" ]
Convert values from LDAP. @return array
[ "Convert", "values", "from", "LDAP", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/AttributeValueResolver.php#L50-L61
28,084
ldaptools/ldaptools
src/LdapTools/Resolver/AttributeValueResolver.php
AttributeValueResolver.convert
protected function convert(array $attributes, $toLdap = true) { $direction = $toLdap ? 'toLdap' : 'fromLdap'; foreach ($attributes as $attribute => $values) { // No converter, but the value should still be encoded. if (!$this->schema->hasConverter($attribute) && !isset($this->converted[$attribute])) { $attributes[$attribute] = $this->encodeValues($values); // Only continue if it has a converter and has not already been converted. } elseif ($this->schema->hasConverter($attribute) && !in_array($attribute, $this->converted)) { $values = $this->getConvertedValues($values, $attribute, $direction); if (in_array($attribute, $this->aggregated)) { $attribute = $this->schema->getAttributeToLdap($attribute); } $attributes[$attribute] = (count($values) == 1) ? reset($values) : $values; } } return $this->removeValuesFromEntry($attributes, array_merge($this->aggregated, $this->remove)); }
php
protected function convert(array $attributes, $toLdap = true) { $direction = $toLdap ? 'toLdap' : 'fromLdap'; foreach ($attributes as $attribute => $values) { // No converter, but the value should still be encoded. if (!$this->schema->hasConverter($attribute) && !isset($this->converted[$attribute])) { $attributes[$attribute] = $this->encodeValues($values); // Only continue if it has a converter and has not already been converted. } elseif ($this->schema->hasConverter($attribute) && !in_array($attribute, $this->converted)) { $values = $this->getConvertedValues($values, $attribute, $direction); if (in_array($attribute, $this->aggregated)) { $attribute = $this->schema->getAttributeToLdap($attribute); } $attributes[$attribute] = (count($values) == 1) ? reset($values) : $values; } } return $this->removeValuesFromEntry($attributes, array_merge($this->aggregated, $this->remove)); }
[ "protected", "function", "convert", "(", "array", "$", "attributes", ",", "$", "toLdap", "=", "true", ")", "{", "$", "direction", "=", "$", "toLdap", "?", "'toLdap'", ":", "'fromLdap'", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute", "=>", "$", "values", ")", "{", "// No converter, but the value should still be encoded.", "if", "(", "!", "$", "this", "->", "schema", "->", "hasConverter", "(", "$", "attribute", ")", "&&", "!", "isset", "(", "$", "this", "->", "converted", "[", "$", "attribute", "]", ")", ")", "{", "$", "attributes", "[", "$", "attribute", "]", "=", "$", "this", "->", "encodeValues", "(", "$", "values", ")", ";", "// Only continue if it has a converter and has not already been converted.", "}", "elseif", "(", "$", "this", "->", "schema", "->", "hasConverter", "(", "$", "attribute", ")", "&&", "!", "in_array", "(", "$", "attribute", ",", "$", "this", "->", "converted", ")", ")", "{", "$", "values", "=", "$", "this", "->", "getConvertedValues", "(", "$", "values", ",", "$", "attribute", ",", "$", "direction", ")", ";", "if", "(", "in_array", "(", "$", "attribute", ",", "$", "this", "->", "aggregated", ")", ")", "{", "$", "attribute", "=", "$", "this", "->", "schema", "->", "getAttributeToLdap", "(", "$", "attribute", ")", ";", "}", "$", "attributes", "[", "$", "attribute", "]", "=", "(", "count", "(", "$", "values", ")", "==", "1", ")", "?", "reset", "(", "$", "values", ")", ":", "$", "values", ";", "}", "}", "return", "$", "this", "->", "removeValuesFromEntry", "(", "$", "attributes", ",", "array_merge", "(", "$", "this", "->", "aggregated", ",", "$", "this", "->", "remove", ")", ")", ";", "}" ]
Perform the attribute conversion process. @param array $attributes @param bool $toLdap @return array
[ "Perform", "the", "attribute", "conversion", "process", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/AttributeValueResolver.php#L80-L99
28,085
ldaptools/ldaptools
src/LdapTools/Hydrator/HydrateQueryTrait.php
HydrateQueryTrait.mergeOrderByAttributes
protected function mergeOrderByAttributes(array $attributes, $alias = null) { if (!$this->isWildCardSelection() && !empty($this->orderBy)) { $orderBy = $this->getAttributesForAlias(array_keys($this->orderBy), $alias); $lcAttributes = array_map('strtolower', $attributes); foreach ($orderBy as $attribute) { if (!in_array(strtolower($attribute), $lcAttributes)) { $attributes[] = $attribute; } } } return $attributes; }
php
protected function mergeOrderByAttributes(array $attributes, $alias = null) { if (!$this->isWildCardSelection() && !empty($this->orderBy)) { $orderBy = $this->getAttributesForAlias(array_keys($this->orderBy), $alias); $lcAttributes = array_map('strtolower', $attributes); foreach ($orderBy as $attribute) { if (!in_array(strtolower($attribute), $lcAttributes)) { $attributes[] = $attribute; } } } return $attributes; }
[ "protected", "function", "mergeOrderByAttributes", "(", "array", "$", "attributes", ",", "$", "alias", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "isWildCardSelection", "(", ")", "&&", "!", "empty", "(", "$", "this", "->", "orderBy", ")", ")", "{", "$", "orderBy", "=", "$", "this", "->", "getAttributesForAlias", "(", "array_keys", "(", "$", "this", "->", "orderBy", ")", ",", "$", "alias", ")", ";", "$", "lcAttributes", "=", "array_map", "(", "'strtolower'", ",", "$", "attributes", ")", ";", "foreach", "(", "$", "orderBy", "as", "$", "attribute", ")", "{", "if", "(", "!", "in_array", "(", "strtolower", "(", "$", "attribute", ")", ",", "$", "lcAttributes", ")", ")", "{", "$", "attributes", "[", "]", "=", "$", "attribute", ";", "}", "}", "}", "return", "$", "attributes", ";", "}" ]
If any attributes that were requested to be ordered by are not explicitly in the attribute selection, add them. @param array $attributes @param null|string $alias @return array
[ "If", "any", "attributes", "that", "were", "requested", "to", "be", "ordered", "by", "are", "not", "explicitly", "in", "the", "attribute", "selection", "add", "them", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/HydrateQueryTrait.php#L32-L45
28,086
ldaptools/ldaptools
src/LdapTools/Hydrator/HydrateQueryTrait.php
HydrateQueryTrait.getSelectedQueryAttributes
protected function getSelectedQueryAttributes(array $attributes, LdapObjectSchema $schema = null) { // Interpret a single wildcard as only schema attributes. if ($schema && !empty($attributes) && $attributes[0] == '*') { $attributes = array_keys($schema->getAttributeMap()); // Interpret a double wildcard as all LDAP attributes even if they aren't in the schema file. } elseif ($schema && !empty($attributes) && $attributes[0] == '**') { $attributes = ['*']; } return $attributes; }
php
protected function getSelectedQueryAttributes(array $attributes, LdapObjectSchema $schema = null) { // Interpret a single wildcard as only schema attributes. if ($schema && !empty($attributes) && $attributes[0] == '*') { $attributes = array_keys($schema->getAttributeMap()); // Interpret a double wildcard as all LDAP attributes even if they aren't in the schema file. } elseif ($schema && !empty($attributes) && $attributes[0] == '**') { $attributes = ['*']; } return $attributes; }
[ "protected", "function", "getSelectedQueryAttributes", "(", "array", "$", "attributes", ",", "LdapObjectSchema", "$", "schema", "=", "null", ")", "{", "// Interpret a single wildcard as only schema attributes.", "if", "(", "$", "schema", "&&", "!", "empty", "(", "$", "attributes", ")", "&&", "$", "attributes", "[", "0", "]", "==", "'*'", ")", "{", "$", "attributes", "=", "array_keys", "(", "$", "schema", "->", "getAttributeMap", "(", ")", ")", ";", "// Interpret a double wildcard as all LDAP attributes even if they aren't in the schema file.", "}", "elseif", "(", "$", "schema", "&&", "!", "empty", "(", "$", "attributes", ")", "&&", "$", "attributes", "[", "0", "]", "==", "'**'", ")", "{", "$", "attributes", "=", "[", "'*'", "]", ";", "}", "return", "$", "attributes", ";", "}" ]
Determine what attributes should be selected. This helps account for all attributes being selected both within and out of the context of a schema. @param array $attributes @param LdapObjectSchema|null $schema @return array
[ "Determine", "what", "attributes", "should", "be", "selected", ".", "This", "helps", "account", "for", "all", "attributes", "being", "selected", "both", "within", "and", "out", "of", "the", "context", "of", "a", "schema", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/HydrateQueryTrait.php#L55-L66
28,087
ldaptools/ldaptools
src/LdapTools/Hydrator/HydrateQueryTrait.php
HydrateQueryTrait.getAttributesToLdap
protected function getAttributesToLdap(array $attributes, $translate, LdapObjectSchema $schema = null, $alias = null) { // First determine if this was some sort of wildcard selection $attributes = $this->getSelectedQueryAttributes($attributes, $schema); // This will return only the attributes for the current alias, minus the possible alias prefix. if ($schema) { $attributes = $this->getAttributesForAlias($attributes, $alias); } // If we still have an empty array here, then fill it with the defaults because nothing was selected specifically. if ($schema && empty($attributes)) { $attributes = $schema->getAttributesToSelect(); } // At this point we add any orderBy attributes that are not being specifically selected already. if (!empty($this->orderBy)) { $attributes = $this->mergeOrderByAttributes($attributes, $alias); } if ($schema && $translate) { $newAttributes = []; foreach ($attributes as $attribute) { $newAttributes[] = $schema->getAttributeToLdap($attribute); } $attributes = $newAttributes; } return $attributes; }
php
protected function getAttributesToLdap(array $attributes, $translate, LdapObjectSchema $schema = null, $alias = null) { // First determine if this was some sort of wildcard selection $attributes = $this->getSelectedQueryAttributes($attributes, $schema); // This will return only the attributes for the current alias, minus the possible alias prefix. if ($schema) { $attributes = $this->getAttributesForAlias($attributes, $alias); } // If we still have an empty array here, then fill it with the defaults because nothing was selected specifically. if ($schema && empty($attributes)) { $attributes = $schema->getAttributesToSelect(); } // At this point we add any orderBy attributes that are not being specifically selected already. if (!empty($this->orderBy)) { $attributes = $this->mergeOrderByAttributes($attributes, $alias); } if ($schema && $translate) { $newAttributes = []; foreach ($attributes as $attribute) { $newAttributes[] = $schema->getAttributeToLdap($attribute); } $attributes = $newAttributes; } return $attributes; }
[ "protected", "function", "getAttributesToLdap", "(", "array", "$", "attributes", ",", "$", "translate", ",", "LdapObjectSchema", "$", "schema", "=", "null", ",", "$", "alias", "=", "null", ")", "{", "// First determine if this was some sort of wildcard selection", "$", "attributes", "=", "$", "this", "->", "getSelectedQueryAttributes", "(", "$", "attributes", ",", "$", "schema", ")", ";", "// This will return only the attributes for the current alias, minus the possible alias prefix.", "if", "(", "$", "schema", ")", "{", "$", "attributes", "=", "$", "this", "->", "getAttributesForAlias", "(", "$", "attributes", ",", "$", "alias", ")", ";", "}", "// If we still have an empty array here, then fill it with the defaults because nothing was selected specifically.", "if", "(", "$", "schema", "&&", "empty", "(", "$", "attributes", ")", ")", "{", "$", "attributes", "=", "$", "schema", "->", "getAttributesToSelect", "(", ")", ";", "}", "// At this point we add any orderBy attributes that are not being specifically selected already.", "if", "(", "!", "empty", "(", "$", "this", "->", "orderBy", ")", ")", "{", "$", "attributes", "=", "$", "this", "->", "mergeOrderByAttributes", "(", "$", "attributes", ",", "$", "alias", ")", ";", "}", "if", "(", "$", "schema", "&&", "$", "translate", ")", "{", "$", "newAttributes", "=", "[", "]", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute", ")", "{", "$", "newAttributes", "[", "]", "=", "$", "schema", "->", "getAttributeToLdap", "(", "$", "attribute", ")", ";", "}", "$", "attributes", "=", "$", "newAttributes", ";", "}", "return", "$", "attributes", ";", "}" ]
Performs the logic needed to determine what attributes were actually selected, or should be selected, when going to LDAP and whether they should be returned as schema translated names. @param array $attributes @param bool @param LdapObjectSchema|null $schema @param null|string $alias @return array
[ "Performs", "the", "logic", "needed", "to", "determine", "what", "attributes", "were", "actually", "selected", "or", "should", "be", "selected", "when", "going", "to", "LDAP", "and", "whether", "they", "should", "be", "returned", "as", "schema", "translated", "names", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/HydrateQueryTrait.php#L98-L124
28,088
ldaptools/ldaptools
src/LdapTools/Utilities/DialInData.php
DialInData.toBinary
public function toBinary() { $binary = hex2bin(str_pad(dechex(ord($this->signature)), 2, 0, STR_PAD_LEFT)); $binary .= hex2bin($this->dec2hex($this->userPrivilege)); $binary .= hex2bin($this->callbackPhoneNumber); return $binary; }
php
public function toBinary() { $binary = hex2bin(str_pad(dechex(ord($this->signature)), 2, 0, STR_PAD_LEFT)); $binary .= hex2bin($this->dec2hex($this->userPrivilege)); $binary .= hex2bin($this->callbackPhoneNumber); return $binary; }
[ "public", "function", "toBinary", "(", ")", "{", "$", "binary", "=", "hex2bin", "(", "str_pad", "(", "dechex", "(", "ord", "(", "$", "this", "->", "signature", ")", ")", ",", "2", ",", "0", ",", "STR_PAD_LEFT", ")", ")", ";", "$", "binary", ".=", "hex2bin", "(", "$", "this", "->", "dec2hex", "(", "$", "this", "->", "userPrivilege", ")", ")", ";", "$", "binary", ".=", "hex2bin", "(", "$", "this", "->", "callbackPhoneNumber", ")", ";", "return", "$", "binary", ";", "}" ]
Get the binary representation of the dial-in data for the userParameters value. @return string
[ "Get", "the", "binary", "representation", "of", "the", "dial", "-", "in", "data", "for", "the", "userParameters", "value", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/DialInData.php#L123-L130
28,089
ldaptools/ldaptools
src/LdapTools/Connection/BindUserStrategy.php
BindUserStrategy.getInstance
public static function getInstance(DomainConfiguration $config) { if (LdapConnection::TYPE_AD == $config->getLdapType()) { return new ADBindUserStrategy($config); } else { return new self($config); } }
php
public static function getInstance(DomainConfiguration $config) { if (LdapConnection::TYPE_AD == $config->getLdapType()) { return new ADBindUserStrategy($config); } else { return new self($config); } }
[ "public", "static", "function", "getInstance", "(", "DomainConfiguration", "$", "config", ")", "{", "if", "(", "LdapConnection", "::", "TYPE_AD", "==", "$", "config", "->", "getLdapType", "(", ")", ")", "{", "return", "new", "ADBindUserStrategy", "(", "$", "config", ")", ";", "}", "else", "{", "return", "new", "self", "(", "$", "config", ")", ";", "}", "}" ]
Given the LDAP type, determine the BindStrategy to use. @param DomainConfiguration $config @return ADBindUserStrategy|BindUserStrategy
[ "Given", "the", "LDAP", "type", "determine", "the", "BindStrategy", "to", "use", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/BindUserStrategy.php#L59-L66
28,090
ldaptools/ldaptools
src/LdapTools/Connection/BindUserStrategy.php
BindUserStrategy.getUsername
public function getUsername($username) { if ($this->isValidUserDn($username)) { return $username; } $replacements = [ $username, $this->config->getDomainName(), ]; return preg_replace($this->params, $replacements, $this->bindFormat); }
php
public function getUsername($username) { if ($this->isValidUserDn($username)) { return $username; } $replacements = [ $username, $this->config->getDomainName(), ]; return preg_replace($this->params, $replacements, $this->bindFormat); }
[ "public", "function", "getUsername", "(", "$", "username", ")", "{", "if", "(", "$", "this", "->", "isValidUserDn", "(", "$", "username", ")", ")", "{", "return", "$", "username", ";", "}", "$", "replacements", "=", "[", "$", "username", ",", "$", "this", "->", "config", "->", "getDomainName", "(", ")", ",", "]", ";", "return", "preg_replace", "(", "$", "this", "->", "params", ",", "$", "replacements", ",", "$", "this", "->", "bindFormat", ")", ";", "}" ]
Determine the format to use for a bind username going to LDAP. @param string $username @return string
[ "Determine", "the", "format", "to", "use", "for", "a", "bind", "username", "going", "to", "LDAP", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/BindUserStrategy.php#L74-L85
28,091
ldaptools/ldaptools
src/LdapTools/Ldif/Ldif.php
Ldif.addEntry
public function addEntry(LdifEntryInterface ...$entries) { foreach ($entries as $entry) { $this->entries[] = $entry; } return $this; }
php
public function addEntry(LdifEntryInterface ...$entries) { foreach ($entries as $entry) { $this->entries[] = $entry; } return $this; }
[ "public", "function", "addEntry", "(", "LdifEntryInterface", "...", "$", "entries", ")", "{", "foreach", "(", "$", "entries", "as", "$", "entry", ")", "{", "$", "this", "->", "entries", "[", "]", "=", "$", "entry", ";", "}", "return", "$", "this", ";", "}" ]
Add one or more LDIF entry objects. @param LdifEntryInterface[] ...$entries @return $this
[ "Add", "one", "or", "more", "LDIF", "entry", "objects", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/Ldif.php#L160-L167
28,092
ldaptools/ldaptools
src/LdapTools/Ldif/Ldif.php
Ldif.toString
public function toString() { $ldif = $this->addCommentsToString(''); if (!is_null($this->version)) { $ldif .= $this->getLdifLine(self::DIRECTIVE_VERSION, $this->version); } foreach ($this->entries as $entry) { $this->setupEntry($entry); $ldif .= $this->lineEnding.$entry->toString(); } return $ldif; }
php
public function toString() { $ldif = $this->addCommentsToString(''); if (!is_null($this->version)) { $ldif .= $this->getLdifLine(self::DIRECTIVE_VERSION, $this->version); } foreach ($this->entries as $entry) { $this->setupEntry($entry); $ldif .= $this->lineEnding.$entry->toString(); } return $ldif; }
[ "public", "function", "toString", "(", ")", "{", "$", "ldif", "=", "$", "this", "->", "addCommentsToString", "(", "''", ")", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "version", ")", ")", "{", "$", "ldif", ".=", "$", "this", "->", "getLdifLine", "(", "self", "::", "DIRECTIVE_VERSION", ",", "$", "this", "->", "version", ")", ";", "}", "foreach", "(", "$", "this", "->", "entries", "as", "$", "entry", ")", "{", "$", "this", "->", "setupEntry", "(", "$", "entry", ")", ";", "$", "ldif", ".=", "$", "this", "->", "lineEnding", ".", "$", "entry", "->", "toString", "(", ")", ";", "}", "return", "$", "ldif", ";", "}" ]
Get the string representation of the LDIF object with all of the entries it has. @return string
[ "Get", "the", "string", "representation", "of", "the", "LDIF", "object", "with", "all", "of", "the", "entries", "it", "has", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/Ldif.php#L184-L196
28,093
ldaptools/ldaptools
src/LdapTools/Ldif/Ldif.php
Ldif.toOperations
public function toOperations() { $operations = []; foreach ($this->entries as $entry) { $this->setupEntry($entry); $operations[] = $entry->toOperation(); } return $operations; }
php
public function toOperations() { $operations = []; foreach ($this->entries as $entry) { $this->setupEntry($entry); $operations[] = $entry->toOperation(); } return $operations; }
[ "public", "function", "toOperations", "(", ")", "{", "$", "operations", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "entries", "as", "$", "entry", ")", "{", "$", "this", "->", "setupEntry", "(", "$", "entry", ")", ";", "$", "operations", "[", "]", "=", "$", "entry", "->", "toOperation", "(", ")", ";", "}", "return", "$", "operations", ";", "}" ]
Get all of the operations represented by all of the entries for this LDIF object. @return LdapOperationInterface[]
[ "Get", "all", "of", "the", "operations", "represented", "by", "all", "of", "the", "entries", "for", "this", "LDIF", "object", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/Ldif.php#L203-L213
28,094
ldaptools/ldaptools
src/LdapTools/Security/Flags.php
Flags.remove
public function remove(...$flags) { foreach ($flags as $flag) { if ($this->has($flag)) { $this->flags = $this->flags ^ (int) $flag; } } return $this; }
php
public function remove(...$flags) { foreach ($flags as $flag) { if ($this->has($flag)) { $this->flags = $this->flags ^ (int) $flag; } } return $this; }
[ "public", "function", "remove", "(", "...", "$", "flags", ")", "{", "foreach", "(", "$", "flags", "as", "$", "flag", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "flag", ")", ")", "{", "$", "this", "->", "flags", "=", "$", "this", "->", "flags", "^", "(", "int", ")", "$", "flag", ";", "}", "}", "return", "$", "this", ";", "}" ]
Remove a flag from the value. @param int[] ...$flags @return $this
[ "Remove", "a", "flag", "from", "the", "value", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Flags.php#L56-L65
28,095
ldaptools/ldaptools
src/LdapTools/LdapManager.php
LdapManager.addConnection
public function addConnection(LdapConnectionInterface ...$connections) { foreach ($connections as $connection) { $this->domains[$connection->getConfig()->getDomainName()] = $connection->getConfig(); $this->connections[$connection->getConfig()->getDomainName()] = $connection; } return $this; }
php
public function addConnection(LdapConnectionInterface ...$connections) { foreach ($connections as $connection) { $this->domains[$connection->getConfig()->getDomainName()] = $connection->getConfig(); $this->connections[$connection->getConfig()->getDomainName()] = $connection; } return $this; }
[ "public", "function", "addConnection", "(", "LdapConnectionInterface", "...", "$", "connections", ")", "{", "foreach", "(", "$", "connections", "as", "$", "connection", ")", "{", "$", "this", "->", "domains", "[", "$", "connection", "->", "getConfig", "(", ")", "->", "getDomainName", "(", ")", "]", "=", "$", "connection", "->", "getConfig", "(", ")", ";", "$", "this", "->", "connections", "[", "$", "connection", "->", "getConfig", "(", ")", "->", "getDomainName", "(", ")", "]", "=", "$", "connection", ";", "}", "return", "$", "this", ";", "}" ]
Explicitly add connections using already constructed connection objects. @param Connection\LdapConnectionInterface[] $connections @return $this
[ "Explicitly", "add", "connections", "using", "already", "constructed", "connection", "objects", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/LdapManager.php#L144-L152
28,096
ldaptools/ldaptools
src/LdapTools/LdapManager.php
LdapManager.getConnection
public function getConnection($domain = null) { $domain = $domain ?: $this->context; $this->validateDomainName($domain); if (!$this->connections[$domain]) { $this->connections[$domain] = new LdapConnection( $this->domains[$domain], $this->config->getEventDispatcher(), $this->config->getLogger(), $this->getCache() ); } return $this->connections[$domain]; }
php
public function getConnection($domain = null) { $domain = $domain ?: $this->context; $this->validateDomainName($domain); if (!$this->connections[$domain]) { $this->connections[$domain] = new LdapConnection( $this->domains[$domain], $this->config->getEventDispatcher(), $this->config->getLogger(), $this->getCache() ); } return $this->connections[$domain]; }
[ "public", "function", "getConnection", "(", "$", "domain", "=", "null", ")", "{", "$", "domain", "=", "$", "domain", "?", ":", "$", "this", "->", "context", ";", "$", "this", "->", "validateDomainName", "(", "$", "domain", ")", ";", "if", "(", "!", "$", "this", "->", "connections", "[", "$", "domain", "]", ")", "{", "$", "this", "->", "connections", "[", "$", "domain", "]", "=", "new", "LdapConnection", "(", "$", "this", "->", "domains", "[", "$", "domain", "]", ",", "$", "this", "->", "config", "->", "getEventDispatcher", "(", ")", ",", "$", "this", "->", "config", "->", "getLogger", "(", ")", ",", "$", "this", "->", "getCache", "(", ")", ")", ";", "}", "return", "$", "this", "->", "connections", "[", "$", "domain", "]", ";", "}" ]
Get the Ldap Connection object. By default it will get the connection of the domain currently in context. To get a different domain connection pass the domain name as a parameter. @param null|string $domain @return Connection\LdapConnectionInterface
[ "Get", "the", "Ldap", "Connection", "object", ".", "By", "default", "it", "will", "get", "the", "connection", "of", "the", "domain", "currently", "in", "context", ".", "To", "get", "a", "different", "domain", "connection", "pass", "the", "domain", "name", "as", "a", "parameter", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/LdapManager.php#L161-L176
28,097
ldaptools/ldaptools
src/LdapTools/LdapManager.php
LdapManager.createLdapObject
public function createLdapObject($type = null) { $creator = new LdapObjectCreator( $this->getConnection(), $this->getSchemaFactory(), $this->config->getEventDispatcher() ); if ($type) { $creator->create($type); } return $creator; }
php
public function createLdapObject($type = null) { $creator = new LdapObjectCreator( $this->getConnection(), $this->getSchemaFactory(), $this->config->getEventDispatcher() ); if ($type) { $creator->create($type); } return $creator; }
[ "public", "function", "createLdapObject", "(", "$", "type", "=", "null", ")", "{", "$", "creator", "=", "new", "LdapObjectCreator", "(", "$", "this", "->", "getConnection", "(", ")", ",", "$", "this", "->", "getSchemaFactory", "(", ")", ",", "$", "this", "->", "config", "->", "getEventDispatcher", "(", ")", ")", ";", "if", "(", "$", "type", ")", "{", "$", "creator", "->", "create", "(", "$", "type", ")", ";", "}", "return", "$", "creator", ";", "}" ]
Get a LdapObjectCreator object. @param string|null $type @return LdapObjectCreator
[ "Get", "a", "LdapObjectCreator", "object", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/LdapManager.php#L194-L206
28,098
ldaptools/ldaptools
src/LdapTools/LdapManager.php
LdapManager.getRepository
public function getRepository($type) { try { $ldapObjectSchema = $this->getLdapObjectSchema($type); $repositoryClass = $ldapObjectSchema->getRepository(); if (!class_exists($repositoryClass)) { throw new \RuntimeException(sprintf('Repository class "%s" not found.', $repositoryClass)); } $repository = new $repositoryClass($ldapObjectSchema, $this->getConnection()); if (!($repository instanceof LdapObjectRepository)) { throw new \RuntimeException('Your repository class must extend \LdapTools\Object\LdapObjectRepository.'); } } catch (\Exception $e) { throw new \RuntimeException(sprintf('Unable to load Repository for type "%s": %s', $type, $e->getMessage())); } catch (\Throwable $e) { throw new \RuntimeException(sprintf('Unable to load Repository for type "%s": %s', $type, $e->getMessage())); } return $repository; }
php
public function getRepository($type) { try { $ldapObjectSchema = $this->getLdapObjectSchema($type); $repositoryClass = $ldapObjectSchema->getRepository(); if (!class_exists($repositoryClass)) { throw new \RuntimeException(sprintf('Repository class "%s" not found.', $repositoryClass)); } $repository = new $repositoryClass($ldapObjectSchema, $this->getConnection()); if (!($repository instanceof LdapObjectRepository)) { throw new \RuntimeException('Your repository class must extend \LdapTools\Object\LdapObjectRepository.'); } } catch (\Exception $e) { throw new \RuntimeException(sprintf('Unable to load Repository for type "%s": %s', $type, $e->getMessage())); } catch (\Throwable $e) { throw new \RuntimeException(sprintf('Unable to load Repository for type "%s": %s', $type, $e->getMessage())); } return $repository; }
[ "public", "function", "getRepository", "(", "$", "type", ")", "{", "try", "{", "$", "ldapObjectSchema", "=", "$", "this", "->", "getLdapObjectSchema", "(", "$", "type", ")", ";", "$", "repositoryClass", "=", "$", "ldapObjectSchema", "->", "getRepository", "(", ")", ";", "if", "(", "!", "class_exists", "(", "$", "repositoryClass", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Repository class \"%s\" not found.'", ",", "$", "repositoryClass", ")", ")", ";", "}", "$", "repository", "=", "new", "$", "repositoryClass", "(", "$", "ldapObjectSchema", ",", "$", "this", "->", "getConnection", "(", ")", ")", ";", "if", "(", "!", "(", "$", "repository", "instanceof", "LdapObjectRepository", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Your repository class must extend \\LdapTools\\Object\\LdapObjectRepository.'", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Unable to load Repository for type \"%s\": %s'", ",", "$", "type", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Unable to load Repository for type \"%s\": %s'", ",", "$", "type", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "return", "$", "repository", ";", "}" ]
Get a repository for a specific LDAP object type. @param string $type @return LdapObjectRepository
[ "Get", "a", "repository", "for", "a", "specific", "LDAP", "object", "type", "." ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/LdapManager.php#L224-L243
28,099
ldaptools/ldaptools
src/LdapTools/LdapManager.php
LdapManager.delete
public function delete(LdapObject $ldapObject, $recursively = false) { $this->getObjectManager()->delete($ldapObject, $recursively); return $this; }
php
public function delete(LdapObject $ldapObject, $recursively = false) { $this->getObjectManager()->delete($ldapObject, $recursively); return $this; }
[ "public", "function", "delete", "(", "LdapObject", "$", "ldapObject", ",", "$", "recursively", "=", "false", ")", "{", "$", "this", "->", "getObjectManager", "(", ")", "->", "delete", "(", "$", "ldapObject", ",", "$", "recursively", ")", ";", "return", "$", "this", ";", "}" ]
Delete an object from LDAP. Optionally you can set the second argument to true which sends a control to LDAP to perform a recursive deletion. This is helpful in the case of deleting an OU with with objects underneath it. By setting the second parameter to true the OU and all objects below it would be deleted. Use with care! If recursive deletion does not work, first check that 'accidental deletion' is not enabled on the object (AD). @param LdapObject $ldapObject @param bool $recursively @return $this
[ "Delete", "an", "object", "from", "LDAP", ".", "Optionally", "you", "can", "set", "the", "second", "argument", "to", "true", "which", "sends", "a", "control", "to", "LDAP", "to", "perform", "a", "recursive", "deletion", ".", "This", "is", "helpful", "in", "the", "case", "of", "deleting", "an", "OU", "with", "with", "objects", "underneath", "it", ".", "By", "setting", "the", "second", "parameter", "to", "true", "the", "OU", "and", "all", "objects", "below", "it", "would", "be", "deleted", ".", "Use", "with", "care!" ]
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/LdapManager.php#L269-L274