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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ldaptools/ldaptools | src/LdapTools/Utilities/ConverterUtilitiesTrait.php | ConverterUtilitiesTrait.getCurrentLdapAttributeValue | protected function getCurrentLdapAttributeValue($attribute)
{
if (!$this->getDn() || !$this->getLdapConnection()) {
throw new AttributeConverterException(sprintf('Unable to query for the current "%s" attribute.', $attribute));
}
$query = new LdapQueryBuilder($this->getLdapConnection());
try {
return $query->select($attribute)
->where($query->filter()->present('objectClass'))
->setBaseDn($this->getDn())
->setScopeBase()
->getLdapQuery()
->getSingleScalarOrNullResult();
} catch (EmptyResultException $e) {
throw new AttributeConverterException(sprintf('Unable to find LDAP object: %s', $this->getDn()));
}
} | php | protected function getCurrentLdapAttributeValue($attribute)
{
if (!$this->getDn() || !$this->getLdapConnection()) {
throw new AttributeConverterException(sprintf('Unable to query for the current "%s" attribute.', $attribute));
}
$query = new LdapQueryBuilder($this->getLdapConnection());
try {
return $query->select($attribute)
->where($query->filter()->present('objectClass'))
->setBaseDn($this->getDn())
->setScopeBase()
->getLdapQuery()
->getSingleScalarOrNullResult();
} catch (EmptyResultException $e) {
throw new AttributeConverterException(sprintf('Unable to find LDAP object: %s', $this->getDn()));
}
} | [
"protected",
"function",
"getCurrentLdapAttributeValue",
"(",
"$",
"attribute",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getDn",
"(",
")",
"||",
"!",
"$",
"this",
"->",
"getLdapConnection",
"(",
")",
")",
"{",
"throw",
"new",
"AttributeConverterExceptio... | This can be called to retrieve the current value of an attribute from LDAP.
@param string $attribute The attribute name to query for a value from the converter context
@return array|string|null
@throws AttributeConverterException | [
"This",
"can",
"be",
"called",
"to",
"retrieve",
"the",
"current",
"value",
"of",
"an",
"attribute",
"from",
"LDAP",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ConverterUtilitiesTrait.php#L69-L86 | train |
ldaptools/ldaptools | src/LdapTools/Utilities/ConverterUtilitiesTrait.php | ConverterUtilitiesTrait.modifyMultivaluedAttribute | protected function modifyMultivaluedAttribute(array $values, array $newValues)
{
if ($this->getOperationType() == AttributeConverterInterface::TYPE_CREATE || ($this->getBatch() && $this->getBatch()->isTypeAdd())) {
$values = array_merge($values, $newValues);
} elseif ($this->getBatch() && $this->getBatch()->isTypeReplace()) {
$values = $newValues;
} elseif ($this->getBatch() && $this->getBatch()->isTypeRemove()) {
$values = array_diff($values, $newValues);
}
return $values;
} | php | protected function modifyMultivaluedAttribute(array $values, array $newValues)
{
if ($this->getOperationType() == AttributeConverterInterface::TYPE_CREATE || ($this->getBatch() && $this->getBatch()->isTypeAdd())) {
$values = array_merge($values, $newValues);
} elseif ($this->getBatch() && $this->getBatch()->isTypeReplace()) {
$values = $newValues;
} elseif ($this->getBatch() && $this->getBatch()->isTypeRemove()) {
$values = array_diff($values, $newValues);
}
return $values;
} | [
"protected",
"function",
"modifyMultivaluedAttribute",
"(",
"array",
"$",
"values",
",",
"array",
"$",
"newValues",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getOperationType",
"(",
")",
"==",
"AttributeConverterInterface",
"::",
"TYPE_CREATE",
"||",
"(",
"$",
... | Modifies a multivalued attribute array based off the original values, the new values, and the modification type.
@param array $values
@param array $newValues
@return array | [
"Modifies",
"a",
"multivalued",
"attribute",
"array",
"based",
"off",
"the",
"original",
"values",
"the",
"new",
"values",
"and",
"the",
"modification",
"type",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ConverterUtilitiesTrait.php#L112-L123 | train |
ldaptools/ldaptools | src/LdapTools/Configuration.php | Configuration.getDomainConfiguration | public function getDomainConfiguration($domain = null)
{
if ($domain && isset($this->domains[$domain])) {
return $this->domains[$domain];
} elseif ($domain) {
throw new InvalidArgumentException(sprintf('Domain "%s" not found.', $domain));
} else {
return $this->domains;
}
} | php | public function getDomainConfiguration($domain = null)
{
if ($domain && isset($this->domains[$domain])) {
return $this->domains[$domain];
} elseif ($domain) {
throw new InvalidArgumentException(sprintf('Domain "%s" not found.', $domain));
} else {
return $this->domains;
}
} | [
"public",
"function",
"getDomainConfiguration",
"(",
"$",
"domain",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"domain",
"&&",
"isset",
"(",
"$",
"this",
"->",
"domains",
"[",
"$",
"domain",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"domains",
"["... | Get the DomainConfiguration for a specific domain, or an array of all DomainConfiguration objects if none is
specified.
@param null|string $domain
@return DomainConfiguration[]|DomainConfiguration | [
"Get",
"the",
"DomainConfiguration",
"for",
"a",
"specific",
"domain",
"or",
"an",
"array",
"of",
"all",
"DomainConfiguration",
"objects",
"if",
"none",
"is",
"specified",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Configuration.php#L98-L107 | train |
ldaptools/ldaptools | src/LdapTools/Configuration.php | Configuration.addDomain | public function addDomain(DomainConfiguration ...$domains)
{
foreach ($domains as $domain) {
$this->domains[$domain->getDomainName()] = $domain;
}
return $this;
} | php | public function addDomain(DomainConfiguration ...$domains)
{
foreach ($domains as $domain) {
$this->domains[$domain->getDomainName()] = $domain;
}
return $this;
} | [
"public",
"function",
"addDomain",
"(",
"DomainConfiguration",
"...",
"$",
"domains",
")",
"{",
"foreach",
"(",
"$",
"domains",
"as",
"$",
"domain",
")",
"{",
"$",
"this",
"->",
"domains",
"[",
"$",
"domain",
"->",
"getDomainName",
"(",
")",
"]",
"=",
... | Add domain configurations. Accepts an arbitrary amount of domain configurations.
@param DomainConfiguration $domains,...
@return $this | [
"Add",
"domain",
"configurations",
".",
"Accepts",
"an",
"arbitrary",
"amount",
"of",
"domain",
"configurations",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Configuration.php#L115-L122 | train |
ldaptools/ldaptools | src/LdapTools/Configuration.php | Configuration.setSchemaFormat | public function setSchemaFormat($type)
{
if (!defined('\LdapTools\Factory\SchemaParserFactory::TYPE_'.strtoupper($type))) {
throw new ConfigurationException(sprintf('Unknown schema format "%s".', $type));
}
$this->config['schemaFormat'] = $type;
return $this;
} | php | public function setSchemaFormat($type)
{
if (!defined('\LdapTools\Factory\SchemaParserFactory::TYPE_'.strtoupper($type))) {
throw new ConfigurationException(sprintf('Unknown schema format "%s".', $type));
}
$this->config['schemaFormat'] = $type;
return $this;
} | [
"public",
"function",
"setSchemaFormat",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'\\LdapTools\\Factory\\SchemaParserFactory::TYPE_'",
".",
"strtoupper",
"(",
"$",
"type",
")",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sp... | Set the schema definition format.
@param $type string The schema type (ie. yml).
@return $this
@throws ConfigurationException | [
"Set",
"the",
"schema",
"definition",
"format",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Configuration.php#L181-L189 | train |
ldaptools/ldaptools | src/LdapTools/Configuration.php | Configuration.setCacheType | public function setCacheType($type)
{
trigger_error('The '.__METHOD__.' method is deprecated and will be removed in a later version. Use setCache() instead.', E_USER_DEPRECATED);
if (!defined('\LdapTools\Factory\CacheFactory::TYPE_'.strtoupper($type))) {
throw new ConfigurationException(sprintf('Unknown cache type "%s".', $type));
}
$this->config['cacheType'] = $type;
return $this;
} | php | public function setCacheType($type)
{
trigger_error('The '.__METHOD__.' method is deprecated and will be removed in a later version. Use setCache() instead.', E_USER_DEPRECATED);
if (!defined('\LdapTools\Factory\CacheFactory::TYPE_'.strtoupper($type))) {
throw new ConfigurationException(sprintf('Unknown cache type "%s".', $type));
}
$this->config['cacheType'] = $type;
return $this;
} | [
"public",
"function",
"setCacheType",
"(",
"$",
"type",
")",
"{",
"trigger_error",
"(",
"'The '",
".",
"__METHOD__",
".",
"' method is deprecated and will be removed in a later version. Use setCache() instead.'",
",",
"E_USER_DEPRECATED",
")",
";",
"if",
"(",
"!",
"define... | Set the cache type to use.
@param $type
@return $this
@throws ConfigurationException
@deprecated This function will be removed in a later version. Use setCache() instead. | [
"Set",
"the",
"cache",
"type",
"to",
"use",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Configuration.php#L232-L242 | train |
ldaptools/ldaptools | src/LdapTools/Configuration.php | Configuration.loadDomainConfiguration | protected function loadDomainConfiguration(array $config)
{
try {
foreach ($config['domains'] as $domain => $options) {
$domain = new DomainConfiguration();
$domain->load($options);
$this->addDomain($domain);
}
} catch (ConfigurationException $e) {
throw new ConfigurationException(sprintf("Error in domain config section: %s", $e->getMessage()));
}
} | php | protected function loadDomainConfiguration(array $config)
{
try {
foreach ($config['domains'] as $domain => $options) {
$domain = new DomainConfiguration();
$domain->load($options);
$this->addDomain($domain);
}
} catch (ConfigurationException $e) {
throw new ConfigurationException(sprintf("Error in domain config section: %s", $e->getMessage()));
}
} | [
"protected",
"function",
"loadDomainConfiguration",
"(",
"array",
"$",
"config",
")",
"{",
"try",
"{",
"foreach",
"(",
"$",
"config",
"[",
"'domains'",
"]",
"as",
"$",
"domain",
"=>",
"$",
"options",
")",
"{",
"$",
"domain",
"=",
"new",
"DomainConfiguratio... | Iterates through and loads the domain section of the configuration.
@param $config
@throws ConfigurationException | [
"Iterates",
"through",
"and",
"loads",
"the",
"domain",
"section",
"of",
"the",
"configuration",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Configuration.php#L410-L421 | train |
ldaptools/ldaptools | src/LdapTools/Factory/AttributeConverterFactory.php | AttributeConverterFactory.get | public static function get($name)
{
if (!isset(self::$converterMap[$name])) {
throw new InvalidArgumentException(sprintf('Attribute converter "%s" is not valid.', $name));
}
return self::getInstanceOfConverter($name);
} | php | public static function get($name)
{
if (!isset(self::$converterMap[$name])) {
throw new InvalidArgumentException(sprintf('Attribute converter "%s" is not valid.', $name));
}
return self::getInstanceOfConverter($name);
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"converterMap",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Attribute convert... | Retrieve a registered attribute converter by name.
@param $name
@return AttributeConverterInterface | [
"Retrieve",
"a",
"registered",
"attribute",
"converter",
"by",
"name",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Factory/AttributeConverterFactory.php#L66-L73 | train |
ldaptools/ldaptools | src/LdapTools/Factory/AttributeConverterFactory.php | AttributeConverterFactory.register | public static function register($name, $class)
{
if (isset(self::$converterMap[$name])) {
throw new InvalidArgumentException(
sprintf('The attribute converter name "%s" is already registered.', $name)
);
}
self::$converterMap[$name] = $class;
} | php | public static function register($name, $class)
{
if (isset(self::$converterMap[$name])) {
throw new InvalidArgumentException(
sprintf('The attribute converter name "%s" is already registered.', $name)
);
}
self::$converterMap[$name] = $class;
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"name",
",",
"$",
"class",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"converterMap",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"("... | Registers a converter so it can be retrieved by its name.
@param string $name The actual name for the converter in the schema.
@param string $class The fully qualified class name (ie. '\Foo\Bar\Converter') | [
"Registers",
"a",
"converter",
"so",
"it",
"can",
"be",
"retrieved",
"by",
"its",
"name",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Factory/AttributeConverterFactory.php#L81-L90 | train |
ldaptools/ldaptools | src/LdapTools/Factory/AttributeConverterFactory.php | AttributeConverterFactory.getInstanceOfConverter | protected static function getInstanceOfConverter($name)
{
try {
$converter = new self::$converterMap[$name]();
} catch (\Exception $e) {
throw new \RuntimeException(
sprintf('Unable to load attribute converter "%s": %s', $name, $e->getMessage())
);
}
if (!($converter instanceof AttributeConverterInterface)) {
throw new \RuntimeException(sprintf(
'The attribute converter "%s" must implement \LdapTools\AttributeConverter\AttributeConverterInterface.',
$name
));
}
return $converter;
} | php | protected static function getInstanceOfConverter($name)
{
try {
$converter = new self::$converterMap[$name]();
} catch (\Exception $e) {
throw new \RuntimeException(
sprintf('Unable to load attribute converter "%s": %s', $name, $e->getMessage())
);
}
if (!($converter instanceof AttributeConverterInterface)) {
throw new \RuntimeException(sprintf(
'The attribute converter "%s" must implement \LdapTools\AttributeConverter\AttributeConverterInterface.',
$name
));
}
return $converter;
} | [
"protected",
"static",
"function",
"getInstanceOfConverter",
"(",
"$",
"name",
")",
"{",
"try",
"{",
"$",
"converter",
"=",
"new",
"self",
"::",
"$",
"converterMap",
"[",
"$",
"name",
"]",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
... | Load a specific converter if needed and send it back.
@param string $name
@return AttributeConverterInterface | [
"Load",
"a",
"specific",
"converter",
"if",
"needed",
"and",
"send",
"it",
"back",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Factory/AttributeConverterFactory.php#L98-L115 | train |
ldaptools/ldaptools | src/LdapTools/Ldif/Entry/LdifEntryTrait.php | LdifEntryTrait.addControlsToString | protected function addControlsToString($ldif)
{
foreach ($this->controls as $control) {
$value = $control->getOid().' '.$control->getCriticality();
if (!is_null($control->getValue())) {
$value .= ' '.$control->getValue();
}
$ldif .= $this->getLdifLine(Ldif::DIRECTIVE_CONTROL, $value);
}
return $ldif;
} | php | protected function addControlsToString($ldif)
{
foreach ($this->controls as $control) {
$value = $control->getOid().' '.$control->getCriticality();
if (!is_null($control->getValue())) {
$value .= ' '.$control->getValue();
}
$ldif .= $this->getLdifLine(Ldif::DIRECTIVE_CONTROL, $value);
}
return $ldif;
} | [
"protected",
"function",
"addControlsToString",
"(",
"$",
"ldif",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"controls",
"as",
"$",
"control",
")",
"{",
"$",
"value",
"=",
"$",
"control",
"->",
"getOid",
"(",
")",
".",
"' '",
".",
"$",
"control",
"... | Add any LDAP controls to the specified LDIF.
@param string $ldif
@return string | [
"Add",
"any",
"LDAP",
"controls",
"to",
"the",
"specified",
"LDIF",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/Entry/LdifEntryTrait.php#L145-L156 | train |
ldaptools/ldaptools | src/LdapTools/Ldif/Entry/LdifEntryTrait.php | LdifEntryTrait.isUnicodePwdHackNeeded | protected function isUnicodePwdHackNeeded()
{
if (!(isset($this->connection) && $this->connection->getConfig()->getLdapType() == LdapConnection::TYPE_AD && isset($this->schema))) {
return false;
}
return $this->schema->hasNamesMappedToAttribute('unicodePwd');
} | php | protected function isUnicodePwdHackNeeded()
{
if (!(isset($this->connection) && $this->connection->getConfig()->getLdapType() == LdapConnection::TYPE_AD && isset($this->schema))) {
return false;
}
return $this->schema->hasNamesMappedToAttribute('unicodePwd');
} | [
"protected",
"function",
"isUnicodePwdHackNeeded",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"isset",
"(",
"$",
"this",
"->",
"connection",
")",
"&&",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"getLdapType",
"(",
")",
"==",
"LdapConne... | Determine if we might need to work around the unusual formatting for unicodePwd. This is pretty much the only
attribute that will ever need a special case for conversion for LDIF creation.
@todo How to get around this? Implementing another attribute conversion type for just a single attribute seems silly.
@link https://support.microsoft.com/en-us/kb/263991
@return bool | [
"Determine",
"if",
"we",
"might",
"need",
"to",
"work",
"around",
"the",
"unusual",
"formatting",
"for",
"unicodePwd",
".",
"This",
"is",
"pretty",
"much",
"the",
"only",
"attribute",
"that",
"will",
"ever",
"need",
"a",
"special",
"case",
"for",
"conversion... | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/Entry/LdifEntryTrait.php#L183-L190 | train |
ldaptools/ldaptools | src/LdapTools/Security/Ace/AceType.php | AceType.setValue | public function setValue($type)
{
if (is_numeric($type) && in_array($type, self::TYPE)) {
$this->type = (int) $type;
} elseif (is_string($type) && array_key_exists(strtoupper($type), self::TYPE)) {
$this->type = self::TYPE[strtoupper($type)];
} elseif (is_string($type) && array_key_exists(strtoupper($type), self::SHORT_NAME)) {
$this->type = self::SHORT_NAME[strtoupper($type)];
} else {
throw new InvalidArgumentException(sprintf('The value "%s" is not a valid AceType.', $type));
}
return $this;
} | php | public function setValue($type)
{
if (is_numeric($type) && in_array($type, self::TYPE)) {
$this->type = (int) $type;
} elseif (is_string($type) && array_key_exists(strtoupper($type), self::TYPE)) {
$this->type = self::TYPE[strtoupper($type)];
} elseif (is_string($type) && array_key_exists(strtoupper($type), self::SHORT_NAME)) {
$this->type = self::SHORT_NAME[strtoupper($type)];
} else {
throw new InvalidArgumentException(sprintf('The value "%s" is not a valid AceType.', $type));
}
return $this;
} | [
"public",
"function",
"setValue",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"type",
")",
"&&",
"in_array",
"(",
"$",
"type",
",",
"self",
"::",
"TYPE",
")",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"(",
"int",
")",
"$",
"t... | Set the type of the Ace.
@param string|int $type
@return $this | [
"Set",
"the",
"type",
"of",
"the",
"Ace",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Ace/AceType.php#L103-L116 | train |
ldaptools/ldaptools | src/LdapTools/Connection/LdapServerPool.php | LdapServerPool.getServer | public function getServer()
{
$servers = $this->getSortedServersArray();
foreach ($servers as $server) {
if ($this->isServerAvailable($server)) {
return $server;
}
}
throw new LdapConnectionException('No LDAP server is available.');
} | php | public function getServer()
{
$servers = $this->getSortedServersArray();
foreach ($servers as $server) {
if ($this->isServerAvailable($server)) {
return $server;
}
}
throw new LdapConnectionException('No LDAP server is available.');
} | [
"public",
"function",
"getServer",
"(",
")",
"{",
"$",
"servers",
"=",
"$",
"this",
"->",
"getSortedServersArray",
"(",
")",
";",
"foreach",
"(",
"$",
"servers",
"as",
"$",
"server",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isServerAvailable",
"(",
"$"... | Retrieve the first available LDAP server.
@return string
@throws LdapConnectionException | [
"Retrieve",
"the",
"first",
"available",
"LDAP",
"server",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/LdapServerPool.php#L88-L99 | train |
ldaptools/ldaptools | src/LdapTools/Connection/LdapServerPool.php | LdapServerPool.isServerAvailable | public function isServerAvailable($server)
{
$result = $this->tcp->connect($server, $this->config->getPort(), $this->config->getConnectTimeout());
if ($result) {
$this->tcp->close();
}
return $result;
} | php | public function isServerAvailable($server)
{
$result = $this->tcp->connect($server, $this->config->getPort(), $this->config->getConnectTimeout());
if ($result) {
$this->tcp->close();
}
return $result;
} | [
"public",
"function",
"isServerAvailable",
"(",
"$",
"server",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"tcp",
"->",
"connect",
"(",
"$",
"server",
",",
"$",
"this",
"->",
"config",
"->",
"getPort",
"(",
")",
",",
"$",
"this",
"->",
"config",... | Check if a LDAP server is up and available.
@param string $server
@return bool | [
"Check",
"if",
"a",
"LDAP",
"server",
"is",
"up",
"and",
"available",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/LdapServerPool.php#L107-L115 | train |
ldaptools/ldaptools | src/LdapTools/Connection/LdapServerPool.php | LdapServerPool.getSortedServersArray | public function getSortedServersArray()
{
$servers = empty($this->config->getServers()) ? $this->getServersFromDns() : $this->config->getServers();
if (self::SELECT_RANDOM == $this->selectionMethod) {
$servers = $this->shuffleServers($servers);
}
return $servers;
} | php | public function getSortedServersArray()
{
$servers = empty($this->config->getServers()) ? $this->getServersFromDns() : $this->config->getServers();
if (self::SELECT_RANDOM == $this->selectionMethod) {
$servers = $this->shuffleServers($servers);
}
return $servers;
} | [
"public",
"function",
"getSortedServersArray",
"(",
")",
"{",
"$",
"servers",
"=",
"empty",
"(",
"$",
"this",
"->",
"config",
"->",
"getServers",
"(",
")",
")",
"?",
"$",
"this",
"->",
"getServersFromDns",
"(",
")",
":",
"$",
"this",
"->",
"config",
"-... | Uses the selected method to decide how to return the server array for the check.
@return array | [
"Uses",
"the",
"selected",
"method",
"to",
"decide",
"how",
"to",
"return",
"the",
"server",
"array",
"for",
"the",
"check",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/LdapServerPool.php#L146-L155 | train |
ldaptools/ldaptools | src/LdapTools/Connection/LdapServerPool.php | LdapServerPool.getServersFromDns | protected function getServersFromDns()
{
$servers = $this->dns->getRecord(LdapUtilities::SRV_PREFIX.$this->config->getDomainName(), DNS_SRV);
if ($servers === false || empty($servers)) {
throw new LdapConnectionException(sprintf(
'No LDAP servers found via DNS for "%s".',
$this->config->getDomainName()
));
}
array_multisort(
array_column($servers, 'pri'), SORT_ASC|SORT_NUMERIC,
array_column($servers, 'weight'), SORT_DESC|SORT_NUMERIC,
$servers
);
return array_column($servers, 'target');
} | php | protected function getServersFromDns()
{
$servers = $this->dns->getRecord(LdapUtilities::SRV_PREFIX.$this->config->getDomainName(), DNS_SRV);
if ($servers === false || empty($servers)) {
throw new LdapConnectionException(sprintf(
'No LDAP servers found via DNS for "%s".',
$this->config->getDomainName()
));
}
array_multisort(
array_column($servers, 'pri'), SORT_ASC|SORT_NUMERIC,
array_column($servers, 'weight'), SORT_DESC|SORT_NUMERIC,
$servers
);
return array_column($servers, 'target');
} | [
"protected",
"function",
"getServersFromDns",
"(",
")",
"{",
"$",
"servers",
"=",
"$",
"this",
"->",
"dns",
"->",
"getRecord",
"(",
"LdapUtilities",
"::",
"SRV_PREFIX",
".",
"$",
"this",
"->",
"config",
"->",
"getDomainName",
"(",
")",
",",
"DNS_SRV",
")",... | Attempt to lookup the LDAP servers from the DNS name.
@return array The LDAP servers.
@throws LdapConnectionException | [
"Attempt",
"to",
"lookup",
"the",
"LDAP",
"servers",
"from",
"the",
"DNS",
"name",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/LdapServerPool.php#L176-L193 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.parseYamlForObject | protected function parseYamlForObject(array $schema, $schemaName, $objectType)
{
$objectSchema = $this->getObjectFromSchema($schema, $objectType);
$objectSchema = $this->mergeAnyExtendedSchemas($objectSchema, $schemaName);
$objectSchema = $this->cleanObjectArray($objectSchema);
$this->updateObjectArray($schemaName, $objectSchema);
$this->validateObjectDirectives($schemaName, $objectType, $objectSchema);
$ldapObjectSchema = new LdapObjectSchema($schemaName, $objectSchema['type']);
foreach ($this->optionMap as $option => $setter) {
if (!array_key_exists($option, $objectSchema)) {
continue;
}
$value = $objectSchema[$option];
if (array_key_exists($option, $this->normalizer)) {
$value = $this->{$this->normalizer[$option]}($value);
}
$ldapObjectSchema->$setter($value);
}
$this->parseConverterOptions($ldapObjectSchema, $objectSchema);
$ldapObjectSchema->setFilter($this->parseFilter($ldapObjectSchema, $objectSchema));
$ldapObjectSchema->setAttributeMap(isset($objectSchema['attributes']) ? $objectSchema['attributes'] : []);
$ldapObjectSchema->setConverterMap($this->parseConverterMap($objectSchema));
$ldapObjectSchema->setControls(...$this->parseControls($objectSchema));
$this->validateObjectSchema($ldapObjectSchema);
return $ldapObjectSchema;
} | php | protected function parseYamlForObject(array $schema, $schemaName, $objectType)
{
$objectSchema = $this->getObjectFromSchema($schema, $objectType);
$objectSchema = $this->mergeAnyExtendedSchemas($objectSchema, $schemaName);
$objectSchema = $this->cleanObjectArray($objectSchema);
$this->updateObjectArray($schemaName, $objectSchema);
$this->validateObjectDirectives($schemaName, $objectType, $objectSchema);
$ldapObjectSchema = new LdapObjectSchema($schemaName, $objectSchema['type']);
foreach ($this->optionMap as $option => $setter) {
if (!array_key_exists($option, $objectSchema)) {
continue;
}
$value = $objectSchema[$option];
if (array_key_exists($option, $this->normalizer)) {
$value = $this->{$this->normalizer[$option]}($value);
}
$ldapObjectSchema->$setter($value);
}
$this->parseConverterOptions($ldapObjectSchema, $objectSchema);
$ldapObjectSchema->setFilter($this->parseFilter($ldapObjectSchema, $objectSchema));
$ldapObjectSchema->setAttributeMap(isset($objectSchema['attributes']) ? $objectSchema['attributes'] : []);
$ldapObjectSchema->setConverterMap($this->parseConverterMap($objectSchema));
$ldapObjectSchema->setControls(...$this->parseControls($objectSchema));
$this->validateObjectSchema($ldapObjectSchema);
return $ldapObjectSchema;
} | [
"protected",
"function",
"parseYamlForObject",
"(",
"array",
"$",
"schema",
",",
"$",
"schemaName",
",",
"$",
"objectType",
")",
"{",
"$",
"objectSchema",
"=",
"$",
"this",
"->",
"getObjectFromSchema",
"(",
"$",
"schema",
",",
"$",
"objectType",
")",
";",
... | Attempt to find the object type definition in the schema and create its object representation.
@param array $schema
@param string $schemaName
@param string $objectType
@return LdapObjectSchema
@throws SchemaParserException | [
"Attempt",
"to",
"find",
"the",
"object",
"type",
"definition",
"in",
"the",
"schema",
"and",
"create",
"its",
"object",
"representation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L179-L206 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.validateSchemaType | protected function validateSchemaType(LdapObjectSchema $schema, array $schemaArray)
{
if (!((bool)count(array_filter(array_keys($schemaArray['attributes']), 'is_string')))) {
throw new SchemaParserException('The attributes for a schema should be an associative array.');
}
if ($schema->getScope() && !in_array($schema->getScope(), QueryOperation::SCOPE)) {
throw new SchemaParserException(sprintf(
'The scope "%s" is not valid. Valid types are: %s',
$schema->getScope(),
implode(', ', QueryOperation::SCOPE)
));
}
} | php | protected function validateSchemaType(LdapObjectSchema $schema, array $schemaArray)
{
if (!((bool)count(array_filter(array_keys($schemaArray['attributes']), 'is_string')))) {
throw new SchemaParserException('The attributes for a schema should be an associative array.');
}
if ($schema->getScope() && !in_array($schema->getScope(), QueryOperation::SCOPE)) {
throw new SchemaParserException(sprintf(
'The scope "%s" is not valid. Valid types are: %s',
$schema->getScope(),
implode(', ', QueryOperation::SCOPE)
));
}
} | [
"protected",
"function",
"validateSchemaType",
"(",
"LdapObjectSchema",
"$",
"schema",
",",
"array",
"$",
"schemaArray",
")",
"{",
"if",
"(",
"!",
"(",
"(",
"bool",
")",
"count",
"(",
"array_filter",
"(",
"array_keys",
"(",
"$",
"schemaArray",
"[",
"'attribu... | Validates some of the schema values to check that they are allowed.
@param LdapObjectSchema $schema
@param array $schemaArray
@throws SchemaParserException | [
"Validates",
"some",
"of",
"the",
"schema",
"values",
"to",
"check",
"that",
"they",
"are",
"allowed",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L261-L273 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.getObjectFromSchema | protected function getObjectFromSchema(array $schema, $objectType)
{
$objectSchema = null;
foreach ($schema['objects'] as $ldapObject) {
if (array_key_exists('type', $ldapObject) && strtolower($ldapObject['type']) == strtolower($objectType)) {
$objectSchema = $ldapObject;
}
}
if (is_null($objectSchema)) {
throw new SchemaParserException(sprintf('Cannot find object type "%s" in schema.', $objectType));
}
return $objectSchema;
} | php | protected function getObjectFromSchema(array $schema, $objectType)
{
$objectSchema = null;
foreach ($schema['objects'] as $ldapObject) {
if (array_key_exists('type', $ldapObject) && strtolower($ldapObject['type']) == strtolower($objectType)) {
$objectSchema = $ldapObject;
}
}
if (is_null($objectSchema)) {
throw new SchemaParserException(sprintf('Cannot find object type "%s" in schema.', $objectType));
}
return $objectSchema;
} | [
"protected",
"function",
"getObjectFromSchema",
"(",
"array",
"$",
"schema",
",",
"$",
"objectType",
")",
"{",
"$",
"objectSchema",
"=",
"null",
";",
"foreach",
"(",
"$",
"schema",
"[",
"'objects'",
"]",
"as",
"$",
"ldapObject",
")",
"{",
"if",
"(",
"arr... | Check for a specific object type in the schema and validate it.
@param array $schema
@param string $objectType
@return array
@throws SchemaParserException | [
"Check",
"for",
"a",
"specific",
"object",
"type",
"in",
"the",
"schema",
"and",
"validate",
"it",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L283-L296 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.updateObjectArray | protected function updateObjectArray($schemaName, $schemaObject)
{
foreach ($this->schemas[$this->schemaFolder][$schemaName]['objects'] as $name => $value) {
if (array_key_exists('type', $value) && $value['type'] == $schemaObject['type']) {
$this->schemas[$this->schemaFolder][$schemaName]['objects'][$name] = $schemaObject;
}
}
} | php | protected function updateObjectArray($schemaName, $schemaObject)
{
foreach ($this->schemas[$this->schemaFolder][$schemaName]['objects'] as $name => $value) {
if (array_key_exists('type', $value) && $value['type'] == $schemaObject['type']) {
$this->schemas[$this->schemaFolder][$schemaName]['objects'][$name] = $schemaObject;
}
}
} | [
"protected",
"function",
"updateObjectArray",
"(",
"$",
"schemaName",
",",
"$",
"schemaObject",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
"[",
"'objects'",
"]",
"as",
... | Update the object in the schema array in case it extended a different object type.
@param string $schemaName
@param array $schemaObject | [
"Update",
"the",
"object",
"in",
"the",
"schema",
"array",
"in",
"case",
"it",
"extended",
"a",
"different",
"object",
"type",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L304-L311 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.parseConverterMap | protected function parseConverterMap(array $objectSchema)
{
$converterMap = [];
if (array_key_exists('converters', $objectSchema)) {
foreach ($objectSchema['converters'] as $converter => $attributes) {
if (is_array($attributes)) {
foreach ($attributes as $attribute) {
$converterMap[$attribute] = $converter;
}
} elseif (is_string($attributes)) {
$converterMap[$attributes] = $converter;
}
}
}
return $converterMap;
} | php | protected function parseConverterMap(array $objectSchema)
{
$converterMap = [];
if (array_key_exists('converters', $objectSchema)) {
foreach ($objectSchema['converters'] as $converter => $attributes) {
if (is_array($attributes)) {
foreach ($attributes as $attribute) {
$converterMap[$attribute] = $converter;
}
} elseif (is_string($attributes)) {
$converterMap[$attributes] = $converter;
}
}
}
return $converterMap;
} | [
"protected",
"function",
"parseConverterMap",
"(",
"array",
"$",
"objectSchema",
")",
"{",
"$",
"converterMap",
"=",
"[",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'converters'",
",",
"$",
"objectSchema",
")",
")",
"{",
"foreach",
"(",
"$",
"objectSchem... | Parse the converters section of an object schema definition to generate the attribute converter map.
@param array $objectSchema
@return array | [
"Parse",
"the",
"converters",
"section",
"of",
"an",
"object",
"schema",
"definition",
"to",
"generate",
"the",
"attribute",
"converter",
"map",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L333-L350 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.parseFilter | protected function parseFilter(LdapObjectSchema $objectSchema, array $objectArray)
{
$filter = array_key_exists('filter', $objectArray) ? $objectArray['filter'] : [];
if (empty($filter) && empty($objectSchema->getObjectClass()) && empty($objectSchema->getObjectCategory())) {
throw new SchemaParserException(sprintf(
'Object type "%s" must have one of the following defined: %s',
$objectSchema->getObjectType(),
implode(', ', ['class', 'category', 'filter'])
));
}
return $this->arrayToOp->getOperatorForSchema($objectSchema, $filter);
} | php | protected function parseFilter(LdapObjectSchema $objectSchema, array $objectArray)
{
$filter = array_key_exists('filter', $objectArray) ? $objectArray['filter'] : [];
if (empty($filter) && empty($objectSchema->getObjectClass()) && empty($objectSchema->getObjectCategory())) {
throw new SchemaParserException(sprintf(
'Object type "%s" must have one of the following defined: %s',
$objectSchema->getObjectType(),
implode(', ', ['class', 'category', 'filter'])
));
}
return $this->arrayToOp->getOperatorForSchema($objectSchema, $filter);
} | [
"protected",
"function",
"parseFilter",
"(",
"LdapObjectSchema",
"$",
"objectSchema",
",",
"array",
"$",
"objectArray",
")",
"{",
"$",
"filter",
"=",
"array_key_exists",
"(",
"'filter'",
",",
"$",
"objectArray",
")",
"?",
"$",
"objectArray",
"[",
"'filter'",
"... | Get the filter for the schema object.
@param LdapObjectSchema $objectSchema
@param array $objectArray
@return \LdapTools\Query\Operator\BaseOperator
@throws SchemaParserException | [
"Get",
"the",
"filter",
"for",
"the",
"schema",
"object",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L360-L373 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.validateObjectSchema | protected function validateObjectSchema($schema)
{
if (empty($schema->getAttributeMap())) {
throw new SchemaParserException(sprintf('Object type "%s" has no attributes defined.', $schema->getObjectType()));
} elseif (!((bool)count(array_filter(array_keys($schema->getAttributeMap()), 'is_string')))) {
throw new SchemaParserException('The attributes for a schema should be an associative array.');
}
if ($schema->getScope() && !in_array($schema->getScope(), QueryOperation::SCOPE)) {
throw new SchemaParserException(sprintf(
'The scope "%s" is not valid. Valid types are: %s',
$schema->getScope(),
implode(', ', QueryOperation::SCOPE)
));
}
} | php | protected function validateObjectSchema($schema)
{
if (empty($schema->getAttributeMap())) {
throw new SchemaParserException(sprintf('Object type "%s" has no attributes defined.', $schema->getObjectType()));
} elseif (!((bool)count(array_filter(array_keys($schema->getAttributeMap()), 'is_string')))) {
throw new SchemaParserException('The attributes for a schema should be an associative array.');
}
if ($schema->getScope() && !in_array($schema->getScope(), QueryOperation::SCOPE)) {
throw new SchemaParserException(sprintf(
'The scope "%s" is not valid. Valid types are: %s',
$schema->getScope(),
implode(', ', QueryOperation::SCOPE)
));
}
} | [
"protected",
"function",
"validateObjectSchema",
"(",
"$",
"schema",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"schema",
"->",
"getAttributeMap",
"(",
")",
")",
")",
"{",
"throw",
"new",
"SchemaParserException",
"(",
"sprintf",
"(",
"'Object type \"%s\" has no att... | Validate that an object schema meets the minimum requirements.
@param LdapObjectSchema $schema
@throws SchemaParserException | [
"Validate",
"that",
"an",
"object",
"schema",
"meets",
"the",
"minimum",
"requirements",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L419-L434 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.parseSchemaNameToArray | protected function parseSchemaNameToArray($schemaName)
{
if (!isset($this->schemas[$this->schemaFolder][$schemaName])) {
$file = $this->getSchemaFileName($this->schemaFolder, $schemaName);
try {
$this->schemas[$this->schemaFolder][$schemaName] = Yaml::parse(file_get_contents($file));
} catch (ParseException $e) {
throw new SchemaParserException(sprintf('Error in configuration file: %s', $e->getMessage()));
}
$this->mergeDefaultSchemaFile($schemaName);
$this->mergeIncludedSchemas($schemaName);
$this->validateSchemaDirectives($schemaName);
}
} | php | protected function parseSchemaNameToArray($schemaName)
{
if (!isset($this->schemas[$this->schemaFolder][$schemaName])) {
$file = $this->getSchemaFileName($this->schemaFolder, $schemaName);
try {
$this->schemas[$this->schemaFolder][$schemaName] = Yaml::parse(file_get_contents($file));
} catch (ParseException $e) {
throw new SchemaParserException(sprintf('Error in configuration file: %s', $e->getMessage()));
}
$this->mergeDefaultSchemaFile($schemaName);
$this->mergeIncludedSchemas($schemaName);
$this->validateSchemaDirectives($schemaName);
}
} | [
"protected",
"function",
"parseSchemaNameToArray",
"(",
"$",
"schemaName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
")",
")",
"{",
"$",
"file",
"=",
... | Given a schema name, parse it into the array.
@param string $schemaName
@throws SchemaParserException | [
"Given",
"a",
"schema",
"name",
"parse",
"it",
"into",
"the",
"array",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L442-L455 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.mergeIncludedSchemas | protected function mergeIncludedSchemas($schemaName)
{
$include = ['include' => [], 'include_default' => []];
foreach (array_keys($include) as $key) {
if (isset($this->schemas[$this->schemaFolder][$schemaName][$key])) {
$include[$key] = $this->schemas[$this->schemaFolder][$schemaName][$key];
$include[$key] = is_array($include[$key]) ? $include[$key] : [$include[$key]];
}
}
foreach ($include['include'] as $schema) {
$this->parseAll($schema);
$this->schemas[$this->schemaFolder][$schemaName]['objects'] = array_merge(
$this->schemas[$this->schemaFolder][$schemaName]['objects'],
$this->schemas[$this->schemaFolder][$schema]['objects']
);
}
$folder = $this->schemaFolder;
$this->schemaFolder = $this->defaultSchemaFolder;
foreach ($include['include_default'] as $schema) {
$this->parseAll($schema);
$this->schemas[$folder][$schemaName]['objects'] = array_merge(
$this->schemas[$folder][$schemaName]['objects'],
$this->schemas[$this->schemaFolder][$schema]['objects']
);
}
$this->schemaFolder = $folder;
} | php | protected function mergeIncludedSchemas($schemaName)
{
$include = ['include' => [], 'include_default' => []];
foreach (array_keys($include) as $key) {
if (isset($this->schemas[$this->schemaFolder][$schemaName][$key])) {
$include[$key] = $this->schemas[$this->schemaFolder][$schemaName][$key];
$include[$key] = is_array($include[$key]) ? $include[$key] : [$include[$key]];
}
}
foreach ($include['include'] as $schema) {
$this->parseAll($schema);
$this->schemas[$this->schemaFolder][$schemaName]['objects'] = array_merge(
$this->schemas[$this->schemaFolder][$schemaName]['objects'],
$this->schemas[$this->schemaFolder][$schema]['objects']
);
}
$folder = $this->schemaFolder;
$this->schemaFolder = $this->defaultSchemaFolder;
foreach ($include['include_default'] as $schema) {
$this->parseAll($schema);
$this->schemas[$folder][$schemaName]['objects'] = array_merge(
$this->schemas[$folder][$schemaName]['objects'],
$this->schemas[$this->schemaFolder][$schema]['objects']
);
}
$this->schemaFolder = $folder;
} | [
"protected",
"function",
"mergeIncludedSchemas",
"(",
"$",
"schemaName",
")",
"{",
"$",
"include",
"=",
"[",
"'include'",
"=>",
"[",
"]",
",",
"'include_default'",
"=>",
"[",
"]",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"include",
")",
"as",
"$... | If the 'include' directive is used, then merge the specified schemas into the current one.
@param string $schemaName
@throws SchemaParserException | [
"If",
"the",
"include",
"directive",
"is",
"used",
"then",
"merge",
"the",
"specified",
"schemas",
"into",
"the",
"current",
"one",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L463-L492 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.mergeDefaultSchemaFile | protected function mergeDefaultSchemaFile($schemaName)
{
if (!isset($this->schemas[$this->schemaFolder][$schemaName]['extends_default'])) {
return;
}
$defaultSchemaName = $this->schemas[$this->schemaFolder][$schemaName]['extends_default'];
$folder = $this->schemaFolder;
$this->schemaFolder = $this->defaultSchemaFolder;
$this->parseAll($defaultSchemaName);
// Perhaps an option at some point to specify the merge action/type? ie. replace vs merge.
$this->schemas[$folder][$schemaName] = array_merge_recursive(
$this->schemas[$this->schemaFolder][$defaultSchemaName],
$this->schemas[$folder][$schemaName]
);
$this->schemaFolder = $folder;
} | php | protected function mergeDefaultSchemaFile($schemaName)
{
if (!isset($this->schemas[$this->schemaFolder][$schemaName]['extends_default'])) {
return;
}
$defaultSchemaName = $this->schemas[$this->schemaFolder][$schemaName]['extends_default'];
$folder = $this->schemaFolder;
$this->schemaFolder = $this->defaultSchemaFolder;
$this->parseAll($defaultSchemaName);
// Perhaps an option at some point to specify the merge action/type? ie. replace vs merge.
$this->schemas[$folder][$schemaName] = array_merge_recursive(
$this->schemas[$this->schemaFolder][$defaultSchemaName],
$this->schemas[$folder][$schemaName]
);
$this->schemaFolder = $folder;
} | [
"protected",
"function",
"mergeDefaultSchemaFile",
"(",
"$",
"schemaName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
"[",
"'extends_default'",
"]",
")",
... | If the 'extends_default' directive is used, then merge the specified default schema.
@param string $schemaName
@throws SchemaParserException | [
"If",
"the",
"extends_default",
"directive",
"is",
"used",
"then",
"merge",
"the",
"specified",
"default",
"schema",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L500-L517 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.mergeAnyExtendedSchemas | protected function mergeAnyExtendedSchemas(array $objectSchema, $schemaName)
{
if (!(isset($objectSchema['extends']) || isset($objectSchema['extends_default']))) {
return $objectSchema;
}
return $this->mergeSchemaObjectArrays($this->getParentSchemaObject($objectSchema, $schemaName), $objectSchema);
} | php | protected function mergeAnyExtendedSchemas(array $objectSchema, $schemaName)
{
if (!(isset($objectSchema['extends']) || isset($objectSchema['extends_default']))) {
return $objectSchema;
}
return $this->mergeSchemaObjectArrays($this->getParentSchemaObject($objectSchema, $schemaName), $objectSchema);
} | [
"protected",
"function",
"mergeAnyExtendedSchemas",
"(",
"array",
"$",
"objectSchema",
",",
"$",
"schemaName",
")",
"{",
"if",
"(",
"!",
"(",
"isset",
"(",
"$",
"objectSchema",
"[",
"'extends'",
"]",
")",
"||",
"isset",
"(",
"$",
"objectSchema",
"[",
"'ext... | If the 'extends' option is given, then merge this schema object with the requested schema object.
@param array $objectSchema
@param string $schemaName
@return array
@throws SchemaParserException | [
"If",
"the",
"extends",
"option",
"is",
"given",
"then",
"merge",
"this",
"schema",
"object",
"with",
"the",
"requested",
"schema",
"object",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L527-L534 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.mergeSchemaObjectArrays | protected function mergeSchemaObjectArrays($parent, $schema)
{
// Directives used that exist in the schema being extended, that are arrays, should be merged.
foreach (array_intersect_key($schema, $parent) as $key => $value) {
# Simple merge on non-multidimensional arrays...
if (is_array($value) && count($value) === count($value, COUNT_RECURSIVE)) {
$schema[$key] = array_merge($parent[$key], $value);
# Recursive merge on multidimensional arrays...
} elseif (is_array($value)) {
$schema[$key] = array_merge_recursive($parent[$key], $value);
}
}
// Directives in the parent that have not been defined should be added.
return array_replace($schema, array_diff_key($parent, $schema));
} | php | protected function mergeSchemaObjectArrays($parent, $schema)
{
// Directives used that exist in the schema being extended, that are arrays, should be merged.
foreach (array_intersect_key($schema, $parent) as $key => $value) {
# Simple merge on non-multidimensional arrays...
if (is_array($value) && count($value) === count($value, COUNT_RECURSIVE)) {
$schema[$key] = array_merge($parent[$key], $value);
# Recursive merge on multidimensional arrays...
} elseif (is_array($value)) {
$schema[$key] = array_merge_recursive($parent[$key], $value);
}
}
// Directives in the parent that have not been defined should be added.
return array_replace($schema, array_diff_key($parent, $schema));
} | [
"protected",
"function",
"mergeSchemaObjectArrays",
"(",
"$",
"parent",
",",
"$",
"schema",
")",
"{",
"// Directives used that exist in the schema being extended, that are arrays, should be merged.",
"foreach",
"(",
"array_intersect_key",
"(",
"$",
"schema",
",",
"$",
"parent... | Performs the logic for merging one schema object array with another.
@param array $parent The parent schema object being extended.
@param array $schema The base schema object being defined.
@return array | [
"Performs",
"the",
"logic",
"for",
"merging",
"one",
"schema",
"object",
"array",
"with",
"another",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L543-L558 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.getExtendedDefaultSchemaObject | protected function getExtendedDefaultSchemaObject(array $objectSchema)
{
if (!(is_array($objectSchema['extends_default']) && 2 == count($objectSchema['extends_default']))) {
throw new SchemaParserException('The "extends_default" directive should be an array with exactly 2 values.');
}
$folder = $this->schemaFolder;
$this->schemaFolder = $this->defaultSchemaFolder;
$this->parseAll(reset($objectSchema['extends_default']));
$parent = $this->getObjectFromSchema(
$this->schemas[$this->defaultSchemaFolder][$objectSchema['extends_default'][0]],
$objectSchema['extends_default'][1]
);
$this->schemaFolder = $folder;
return $parent;
} | php | protected function getExtendedDefaultSchemaObject(array $objectSchema)
{
if (!(is_array($objectSchema['extends_default']) && 2 == count($objectSchema['extends_default']))) {
throw new SchemaParserException('The "extends_default" directive should be an array with exactly 2 values.');
}
$folder = $this->schemaFolder;
$this->schemaFolder = $this->defaultSchemaFolder;
$this->parseAll(reset($objectSchema['extends_default']));
$parent = $this->getObjectFromSchema(
$this->schemas[$this->defaultSchemaFolder][$objectSchema['extends_default'][0]],
$objectSchema['extends_default'][1]
);
$this->schemaFolder = $folder;
return $parent;
} | [
"protected",
"function",
"getExtendedDefaultSchemaObject",
"(",
"array",
"$",
"objectSchema",
")",
"{",
"if",
"(",
"!",
"(",
"is_array",
"(",
"$",
"objectSchema",
"[",
"'extends_default'",
"]",
")",
"&&",
"2",
"==",
"count",
"(",
"$",
"objectSchema",
"[",
"'... | If we need to retrieve one of the default schemas, then it's probably the case that the schema folder path was
manually defined. So retrieve the default schema object by parsing the name from the default folder path and then
reset the schema folder back to what it originally was.
@param array $objectSchema
@return array
@throws SchemaParserException | [
"If",
"we",
"need",
"to",
"retrieve",
"one",
"of",
"the",
"default",
"schemas",
"then",
"it",
"s",
"probably",
"the",
"case",
"that",
"the",
"schema",
"folder",
"path",
"was",
"manually",
"defined",
".",
"So",
"retrieve",
"the",
"default",
"schema",
"objec... | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L569-L586 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.getParentSchemaObject | protected function getParentSchemaObject(array $objectSchema, $schemaName)
{
if (isset($objectSchema['extends_default'])) {
$parent = $this->getExtendedDefaultSchemaObject($objectSchema);
} elseif (isset($objectSchema['extends']) && is_string($objectSchema['extends'])) {
$parent = $this->getObjectFromSchema($this->schemas[$this->schemaFolder][$schemaName], $objectSchema['extends']);
} elseif (isset($objectSchema['extends']) && is_array($objectSchema['extends']) && 2 == count($objectSchema['extends'])) {
$name = reset($objectSchema['extends']);
$type = $objectSchema['extends'][1];
$this->parseAll($name);
$parent = $this->getObjectFromSchema($this->schemas[$this->schemaFolder][$name], $type);
} else {
throw new SchemaParserException('The directive "extends" must be a string or array with exactly 2 values.');
}
return $parent;
} | php | protected function getParentSchemaObject(array $objectSchema, $schemaName)
{
if (isset($objectSchema['extends_default'])) {
$parent = $this->getExtendedDefaultSchemaObject($objectSchema);
} elseif (isset($objectSchema['extends']) && is_string($objectSchema['extends'])) {
$parent = $this->getObjectFromSchema($this->schemas[$this->schemaFolder][$schemaName], $objectSchema['extends']);
} elseif (isset($objectSchema['extends']) && is_array($objectSchema['extends']) && 2 == count($objectSchema['extends'])) {
$name = reset($objectSchema['extends']);
$type = $objectSchema['extends'][1];
$this->parseAll($name);
$parent = $this->getObjectFromSchema($this->schemas[$this->schemaFolder][$name], $type);
} else {
throw new SchemaParserException('The directive "extends" must be a string or array with exactly 2 values.');
}
return $parent;
} | [
"protected",
"function",
"getParentSchemaObject",
"(",
"array",
"$",
"objectSchema",
",",
"$",
"schemaName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"objectSchema",
"[",
"'extends_default'",
"]",
")",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getEx... | Determines what parent array object to get based on the directive used.
@param array $objectSchema
@param string $schemaName
@return array
@throws SchemaParserException | [
"Determines",
"what",
"parent",
"array",
"object",
"to",
"get",
"based",
"on",
"the",
"directive",
"used",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L596-L612 | train |
ldaptools/ldaptools | src/LdapTools/Schema/Parser/SchemaYamlParser.php | SchemaYamlParser.getSchemaFileName | protected function getSchemaFileName($folder, $schema)
{
$file = null;
foreach (['yml', 'yaml'] as $ext) {
$fileCheck = $folder.'/'.$schema.'.'.$ext;
if (is_readable($fileCheck)) {
$file = $fileCheck;
break;
}
}
if (is_null($file)) {
throw new SchemaParserException(sprintf('Cannot find schema for "%s" in "%s"', $schema, $folder));
}
return $file;
} | php | protected function getSchemaFileName($folder, $schema)
{
$file = null;
foreach (['yml', 'yaml'] as $ext) {
$fileCheck = $folder.'/'.$schema.'.'.$ext;
if (is_readable($fileCheck)) {
$file = $fileCheck;
break;
}
}
if (is_null($file)) {
throw new SchemaParserException(sprintf('Cannot find schema for "%s" in "%s"', $schema, $folder));
}
return $file;
} | [
"protected",
"function",
"getSchemaFileName",
"(",
"$",
"folder",
",",
"$",
"schema",
")",
"{",
"$",
"file",
"=",
"null",
";",
"foreach",
"(",
"[",
"'yml'",
",",
"'yaml'",
"]",
"as",
"$",
"ext",
")",
"{",
"$",
"fileCheck",
"=",
"$",
"folder",
".",
... | Check for a YML file of the specified schema name and return the full path.
@param string $folder
@param string $schema
@return string
@throws SchemaParserException | [
"Check",
"for",
"a",
"YML",
"file",
"of",
"the",
"specified",
"schema",
"name",
"and",
"return",
"the",
"full",
"path",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L622-L639 | train |
ldaptools/ldaptools | src/LdapTools/AttributeConverter/ConvertPrimaryGroup.php | ConvertPrimaryGroup.validateAndGetGroupSID | protected function validateAndGetGroupSID($name)
{
$query = new LdapQueryBuilder($this->getLdapConnection());
$query->select('objectSid')->where(['objectClass' => 'group', 'cn' => $name]);
// Only validate group group membership on modification.
if ($this->getOperationType() == AttributeConverterInterface::TYPE_MODIFY) {
$query->andWhere(['member' => $this->getDn()]);
}
try {
return $query->andWhere($query->filter()->bitwiseAnd('groupType', GroupType::SecurityEnabled))
->getLdapQuery()
->getSingleScalarResult();
} catch (EmptyResultException $e) {
throw new AttributeConverterException(sprintf(
'Either the group "%s" doesn\'t exist, the user with DN "%s" is not a member of the group, the group'
.' is not a security group, or this group is already their primary group.',
$name,
$this->getDn()
));
}
} | php | protected function validateAndGetGroupSID($name)
{
$query = new LdapQueryBuilder($this->getLdapConnection());
$query->select('objectSid')->where(['objectClass' => 'group', 'cn' => $name]);
// Only validate group group membership on modification.
if ($this->getOperationType() == AttributeConverterInterface::TYPE_MODIFY) {
$query->andWhere(['member' => $this->getDn()]);
}
try {
return $query->andWhere($query->filter()->bitwiseAnd('groupType', GroupType::SecurityEnabled))
->getLdapQuery()
->getSingleScalarResult();
} catch (EmptyResultException $e) {
throw new AttributeConverterException(sprintf(
'Either the group "%s" doesn\'t exist, the user with DN "%s" is not a member of the group, the group'
.' is not a security group, or this group is already their primary group.',
$name,
$this->getDn()
));
}
} | [
"protected",
"function",
"validateAndGetGroupSID",
"(",
"$",
"name",
")",
"{",
"$",
"query",
"=",
"new",
"LdapQueryBuilder",
"(",
"$",
"this",
"->",
"getLdapConnection",
"(",
")",
")",
";",
"$",
"query",
"->",
"select",
"(",
"'objectSid'",
")",
"->",
"wher... | Make sure that the group exists and that the user is already a member of it. If not, at least give an informative
message.
@param string $name The group name.
@return string The text SID of the group.
@throws AttributeConverterException | [
"Make",
"sure",
"that",
"the",
"group",
"exists",
"and",
"that",
"the",
"user",
"is",
"already",
"a",
"member",
"of",
"it",
".",
"If",
"not",
"at",
"least",
"give",
"an",
"informative",
"message",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/AttributeConverter/ConvertPrimaryGroup.php#L73-L94 | train |
ldaptools/ldaptools | src/LdapTools/BatchModify/BatchCollection.php | BatchCollection.add | public function add(Batch ...$batches)
{
foreach ($batches as $batch) {
if (!$this->has($batch)) {
$this->batches[] = $batch;
}
}
return $this;
} | php | public function add(Batch ...$batches)
{
foreach ($batches as $batch) {
if (!$this->has($batch)) {
$this->batches[] = $batch;
}
}
return $this;
} | [
"public",
"function",
"add",
"(",
"Batch",
"...",
"$",
"batches",
")",
"{",
"foreach",
"(",
"$",
"batches",
"as",
"$",
"batch",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"batch",
")",
")",
"{",
"$",
"this",
"->",
"batches",
... | Add an individual batch action to the collection.
@param Batch[] ...$batches
@return $this | [
"Add",
"an",
"individual",
"batch",
"action",
"to",
"the",
"collection",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/BatchModify/BatchCollection.php#L59-L68 | train |
ldaptools/ldaptools | src/LdapTools/BatchModify/BatchCollection.php | BatchCollection.remove | public function remove(Batch ...$batches)
{
foreach ($batches as $batch) {
foreach ($this->batches as $i => $batchItem) {
if ($batchItem === $batch) {
unset($this->batches[$i]);
}
}
}
return $this;
} | php | public function remove(Batch ...$batches)
{
foreach ($batches as $batch) {
foreach ($this->batches as $i => $batchItem) {
if ($batchItem === $batch) {
unset($this->batches[$i]);
}
}
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"Batch",
"...",
"$",
"batches",
")",
"{",
"foreach",
"(",
"$",
"batches",
"as",
"$",
"batch",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"batches",
"as",
"$",
"i",
"=>",
"$",
"batchItem",
")",
"{",
"if",
"(",
... | Remove a specific batch from the collection.
@param Batch[] ...$batches
@return $this | [
"Remove",
"a",
"specific",
"batch",
"from",
"the",
"collection",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/BatchModify/BatchCollection.php#L76-L87 | train |
ldaptools/ldaptools | src/LdapTools/BatchModify/BatchCollection.php | BatchCollection.has | public function has(Batch $batch)
{
foreach ($this->batches as $batchItem) {
if ($batchItem === $batch) {
return true;
}
}
return false;
} | php | public function has(Batch $batch)
{
foreach ($this->batches as $batchItem) {
if ($batchItem === $batch) {
return true;
}
}
return false;
} | [
"public",
"function",
"has",
"(",
"Batch",
"$",
"batch",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"batches",
"as",
"$",
"batchItem",
")",
"{",
"if",
"(",
"$",
"batchItem",
"===",
"$",
"batch",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return"... | Check if a specific batch index exists.
@param Batch $batch
@return bool | [
"Check",
"if",
"a",
"specific",
"batch",
"index",
"exists",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/BatchModify/BatchCollection.php#L95-L103 | train |
ldaptools/ldaptools | src/LdapTools/BatchModify/BatchCollection.php | BatchCollection.getBatchArray | public function getBatchArray()
{
$batchEntry = [];
foreach ($this->batches as $batch) {
$batchEntry[] = $batch->toArray();
}
return $batchEntry;
} | php | public function getBatchArray()
{
$batchEntry = [];
foreach ($this->batches as $batch) {
$batchEntry[] = $batch->toArray();
}
return $batchEntry;
} | [
"public",
"function",
"getBatchArray",
"(",
")",
"{",
"$",
"batchEntry",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"batches",
"as",
"$",
"batch",
")",
"{",
"$",
"batchEntry",
"[",
"]",
"=",
"$",
"batch",
"->",
"toArray",
"(",
")",
";",... | Get an array that represents the array form of each batch action to be sent to LDAP.
@return array | [
"Get",
"an",
"array",
"that",
"represents",
"the",
"array",
"form",
"of",
"each",
"batch",
"action",
"to",
"be",
"sent",
"to",
"LDAP",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/BatchModify/BatchCollection.php#L143-L152 | train |
ldaptools/ldaptools | src/LdapTools/Utilities/ArrayToOperator.php | ArrayToOperator.getOperatorForSchema | public function getOperatorForSchema(LdapObjectSchema $schema, array $filter)
{
$operator = null;
$categoryOperator = $this->getCategoryOperator($schema->getObjectCategory());
$classOperator = $this->getClassOperator($schema->getObjectClass());
if ($classOperator && $categoryOperator) {
$operator = $this->filterBuilder->bAnd($categoryOperator, $classOperator);
} elseif ($categoryOperator) {
$operator = $categoryOperator;
} elseif ($classOperator) {
$operator = $classOperator;
}
return $this->getOperatorForArray($filter, $operator);
} | php | public function getOperatorForSchema(LdapObjectSchema $schema, array $filter)
{
$operator = null;
$categoryOperator = $this->getCategoryOperator($schema->getObjectCategory());
$classOperator = $this->getClassOperator($schema->getObjectClass());
if ($classOperator && $categoryOperator) {
$operator = $this->filterBuilder->bAnd($categoryOperator, $classOperator);
} elseif ($categoryOperator) {
$operator = $categoryOperator;
} elseif ($classOperator) {
$operator = $classOperator;
}
return $this->getOperatorForArray($filter, $operator);
} | [
"public",
"function",
"getOperatorForSchema",
"(",
"LdapObjectSchema",
"$",
"schema",
",",
"array",
"$",
"filter",
")",
"{",
"$",
"operator",
"=",
"null",
";",
"$",
"categoryOperator",
"=",
"$",
"this",
"->",
"getCategoryOperator",
"(",
"$",
"schema",
"->",
... | Given a schema object and a filter array, construct the operator to be used for the schema.
@param LdapObjectSchema $schema
@param array $filter
@return BaseOperator | [
"Given",
"a",
"schema",
"object",
"and",
"a",
"filter",
"array",
"construct",
"the",
"operator",
"to",
"be",
"used",
"for",
"the",
"schema",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ArrayToOperator.php#L80-L96 | train |
ldaptools/ldaptools | src/LdapTools/Query/Builder/FilterBuilder.php | FilterBuilder.getInstance | public static function getInstance(LdapConnectionInterface $connection = null)
{
if ($connection && $connection->getConfig()->getLdapType() == LdapConnection::TYPE_AD) {
$filterBuilder = new ADFilterBuilder();
} else {
$filterBuilder = new self();
}
return $filterBuilder;
} | php | public static function getInstance(LdapConnectionInterface $connection = null)
{
if ($connection && $connection->getConfig()->getLdapType() == LdapConnection::TYPE_AD) {
$filterBuilder = new ADFilterBuilder();
} else {
$filterBuilder = new self();
}
return $filterBuilder;
} | [
"public",
"static",
"function",
"getInstance",
"(",
"LdapConnectionInterface",
"$",
"connection",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"connection",
"&&",
"$",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"getLdapType",
"(",
")",
"==",
"LdapConnection",
... | Get a FilterBuilder instance based on the connection.
@param LdapConnectionInterface|null $connection
@return ADFilterBuilder|FilterBuilder | [
"Get",
"a",
"FilterBuilder",
"instance",
"based",
"on",
"the",
"connection",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Builder/FilterBuilder.php#L37-L46 | train |
ldaptools/ldaptools | src/LdapTools/Query/Builder/FilterBuilder.php | FilterBuilder.in | public function in($attribute, array $values)
{
return new bOr(...array_map(function($v) use ($attribute) {
return $this->eq($attribute, $v);
}, $values));
} | php | public function in($attribute, array $values)
{
return new bOr(...array_map(function($v) use ($attribute) {
return $this->eq($attribute, $v);
}, $values));
} | [
"public",
"function",
"in",
"(",
"$",
"attribute",
",",
"array",
"$",
"values",
")",
"{",
"return",
"new",
"bOr",
"(",
"...",
"array_map",
"(",
"function",
"(",
"$",
"v",
")",
"use",
"(",
"$",
"attribute",
")",
"{",
"return",
"$",
"this",
"->",
"eq... | Check if an attribute value matches any of the values in the list of values provided.
@param string $attribute
@param array $values
@return bOr | [
"Check",
"if",
"an",
"attribute",
"value",
"matches",
"any",
"of",
"the",
"values",
"in",
"the",
"list",
"of",
"values",
"provided",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Builder/FilterBuilder.php#L88-L93 | train |
ldaptools/ldaptools | src/LdapTools/Query/Builder/FilterBuilder.php | FilterBuilder.match | public function match($attribute, $rule, $value, $dnFlag = false)
{
return new MatchingRule($attribute, $rule, $value, $dnFlag);
} | php | public function match($attribute, $rule, $value, $dnFlag = false)
{
return new MatchingRule($attribute, $rule, $value, $dnFlag);
} | [
"public",
"function",
"match",
"(",
"$",
"attribute",
",",
"$",
"rule",
",",
"$",
"value",
",",
"$",
"dnFlag",
"=",
"false",
")",
"{",
"return",
"new",
"MatchingRule",
"(",
"$",
"attribute",
",",
"$",
"rule",
",",
"$",
"value",
",",
"$",
"dnFlag",
... | Perform an extensible match.
@param string|null $attribute
@param string|null $rule
@param mixed $value
@param bool $dnFlag
@return MatchingRule | [
"Perform",
"an",
"extensible",
"match",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Builder/FilterBuilder.php#L263-L266 | train |
ldaptools/ldaptools | src/LdapTools/Utilities/TcpSocket.php | TcpSocket.connect | public function connect($host, $port, $timeout = 1)
{
$this->socket = @stream_socket_client(
"tcp://$host:$port",
$errorNumber,
$errorMessage,
$timeout,
STREAM_CLIENT_CONNECT,
stream_context_create($this->options)
);
return (bool) $this->socket;
} | php | public function connect($host, $port, $timeout = 1)
{
$this->socket = @stream_socket_client(
"tcp://$host:$port",
$errorNumber,
$errorMessage,
$timeout,
STREAM_CLIENT_CONNECT,
stream_context_create($this->options)
);
return (bool) $this->socket;
} | [
"public",
"function",
"connect",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"timeout",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"socket",
"=",
"@",
"stream_socket_client",
"(",
"\"tcp://$host:$port\"",
",",
"$",
"errorNumber",
",",
"$",
"errorMessage",
... | Connect to the host on the port defined for this TCP socket.
@param string $host
@param int $port
@param int $timeout
@return bool | [
"Connect",
"to",
"the",
"host",
"on",
"the",
"port",
"defined",
"for",
"this",
"TCP",
"socket",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/TcpSocket.php#L46-L58 | train |
ldaptools/ldaptools | src/LdapTools/ConfigurationParseTrait.php | ConfigurationParseTrait.getParsedConfig | protected function getParsedConfig(array $config, array $existingConfig, array $configMap, array $required)
{
$parsedConfig = [];
foreach ($config as $key => $value) {
$cfgKey = strtolower($key);
if (!isset($configMap[$cfgKey])) {
throw new ConfigurationException(
sprintf('Option "%s" not recognized.', $key)
);
}
$parsedConfig[$configMap[$cfgKey]] = $value;
}
if (!$this->isParsedConfigValid($parsedConfig, $required)) {
$needed = [];
foreach ($required as $option) {
$needed[] = array_search($option, $configMap);
}
throw new ConfigurationException(
sprintf('Some required configuration options are missing. Required: %s', implode(', ', $needed))
);
}
$existingConfig = array_merge($existingConfig, $parsedConfig);
return array_filter($existingConfig, function ($v) {
return $v !== null && $v !== '';
});
} | php | protected function getParsedConfig(array $config, array $existingConfig, array $configMap, array $required)
{
$parsedConfig = [];
foreach ($config as $key => $value) {
$cfgKey = strtolower($key);
if (!isset($configMap[$cfgKey])) {
throw new ConfigurationException(
sprintf('Option "%s" not recognized.', $key)
);
}
$parsedConfig[$configMap[$cfgKey]] = $value;
}
if (!$this->isParsedConfigValid($parsedConfig, $required)) {
$needed = [];
foreach ($required as $option) {
$needed[] = array_search($option, $configMap);
}
throw new ConfigurationException(
sprintf('Some required configuration options are missing. Required: %s', implode(', ', $needed))
);
}
$existingConfig = array_merge($existingConfig, $parsedConfig);
return array_filter($existingConfig, function ($v) {
return $v !== null && $v !== '';
});
} | [
"protected",
"function",
"getParsedConfig",
"(",
"array",
"$",
"config",
",",
"array",
"$",
"existingConfig",
",",
"array",
"$",
"configMap",
",",
"array",
"$",
"required",
")",
"{",
"$",
"parsedConfig",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"config",
... | Parses a YAML config section and sends it back as the correct config values as an array.
@param array $config The YAML config section as an array.
@param array $existingConfig The config before merging the YAML config.
@param array $configMap The YAML to config key map array.
@param array $required The required options that must be in the array.
@return array The YAML config merged with the existing config.
@throws ConfigurationException | [
"Parses",
"a",
"YAML",
"config",
"section",
"and",
"sends",
"it",
"back",
"as",
"the",
"correct",
"config",
"values",
"as",
"an",
"array",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/ConfigurationParseTrait.php#L32-L60 | train |
ldaptools/ldaptools | src/LdapTools/ConfigurationParseTrait.php | ConfigurationParseTrait.isParsedConfigValid | protected function isParsedConfigValid(array $config, array $required)
{
$inConfig = count(array_intersect_key(array_flip($required), array_filter($config)));
return $inConfig === count($required);
} | php | protected function isParsedConfigValid(array $config, array $required)
{
$inConfig = count(array_intersect_key(array_flip($required), array_filter($config)));
return $inConfig === count($required);
} | [
"protected",
"function",
"isParsedConfigValid",
"(",
"array",
"$",
"config",
",",
"array",
"$",
"required",
")",
"{",
"$",
"inConfig",
"=",
"count",
"(",
"array_intersect_key",
"(",
"array_flip",
"(",
"$",
"required",
")",
",",
"array_filter",
"(",
"$",
"con... | Checks whether all required values for the configuration have been set after the merge.
@param array $config
@param array $required
@return bool | [
"Checks",
"whether",
"all",
"required",
"values",
"for",
"the",
"configuration",
"have",
"been",
"set",
"after",
"the",
"merge",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/ConfigurationParseTrait.php#L69-L74 | train |
ldaptools/ldaptools | src/LdapTools/ConfigurationParseTrait.php | ConfigurationParseTrait.setParsedConfig | protected function setParsedConfig(array $config)
{
foreach ($config as $key => $value) {
$setter = 'set'.ucfirst($key);
$this->$setter($value);
}
} | php | protected function setParsedConfig(array $config)
{
foreach ($config as $key => $value) {
$setter = 'set'.ucfirst($key);
$this->$setter($value);
}
} | [
"protected",
"function",
"setParsedConfig",
"(",
"array",
"$",
"config",
")",
"{",
"foreach",
"(",
"$",
"config",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"setter",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",
"key",
")",
";",
"$",
"this",
"... | Given a config that has been parsed to what the config values should be, call the setters to make
sure all values are validated by any additional logic in the setters.
@param array $config | [
"Given",
"a",
"config",
"that",
"has",
"been",
"parsed",
"to",
"what",
"the",
"config",
"values",
"should",
"be",
"call",
"the",
"setters",
"to",
"make",
"sure",
"all",
"values",
"are",
"validated",
"by",
"any",
"additional",
"logic",
"in",
"the",
"setters... | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/ConfigurationParseTrait.php#L82-L88 | train |
ldaptools/ldaptools | src/LdapTools/Utilities/UserParameters.php | UserParameters.toBinary | public function toBinary()
{
/**
* @todo There is no documentation on the reserved data, but this is how it seems to act. May need to change this.
*/
if (!$this->tsPropertyArray && !$this->dialInData) {
$binary = $this->encodeReservedData('');
} elseif ($this->tsPropertyArray && $this->dialInData) {
$binary = $this->encodeReservedData(self::RESERVED_DATA_VALUE['NPS_RDS']);
} | php | public function toBinary()
{
/**
* @todo There is no documentation on the reserved data, but this is how it seems to act. May need to change this.
*/
if (!$this->tsPropertyArray && !$this->dialInData) {
$binary = $this->encodeReservedData('');
} elseif ($this->tsPropertyArray && $this->dialInData) {
$binary = $this->encodeReservedData(self::RESERVED_DATA_VALUE['NPS_RDS']);
} | [
"public",
"function",
"toBinary",
"(",
")",
"{",
"/**\n * @todo There is no documentation on the reserved data, but this is how it seems to act. May need to change this.\n */",
"if",
"(",
"!",
"$",
"this",
"->",
"tsPropertyArray",
"&&",
"!",
"$",
"this",
"->",
"... | Get the userParameters in binary form that can be saved back to LDAP.
@return string | [
"Get",
"the",
"userParameters",
"in",
"binary",
"form",
"that",
"can",
"be",
"saved",
"back",
"to",
"LDAP",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/UserParameters.php#L115-L124 | train |
ldaptools/ldaptools | src/LdapTools/Hydrator/OperationHydrator.php | OperationHydrator.setDnToUse | protected function setDnToUse(AddOperation $operation)
{
// If the DN was explicitly set, don't do anything.
if ($operation->getDn()) {
return;
}
if (!$this->schema) {
throw new LogicException("You must explicitly set the DN or specify a schema type.");
}
$location = $operation->getLocation() ?: $this->schema->getDefaultContainer();
if (empty($location)) {
throw new LogicException('You must specify a container or OU to place this LDAP object in.');
}
// Handles a possible multi-valued RDN, where each RDN is pieced together with a '+'
$rdn = implode('+', array_map(function($rdn) use ($operation) {
return $rdn.'='.LdapUtilities::escapeValue($operation->getAttributes()[$rdn], null, LDAP_ESCAPE_DN);
}, $this->getRdnFromAttributes(array_keys($operation->getAttributes()))));
$operation->setDn($rdn.','.$this->resolveParameters(['container' => $location])['container']);
} | php | protected function setDnToUse(AddOperation $operation)
{
// If the DN was explicitly set, don't do anything.
if ($operation->getDn()) {
return;
}
if (!$this->schema) {
throw new LogicException("You must explicitly set the DN or specify a schema type.");
}
$location = $operation->getLocation() ?: $this->schema->getDefaultContainer();
if (empty($location)) {
throw new LogicException('You must specify a container or OU to place this LDAP object in.');
}
// Handles a possible multi-valued RDN, where each RDN is pieced together with a '+'
$rdn = implode('+', array_map(function($rdn) use ($operation) {
return $rdn.'='.LdapUtilities::escapeValue($operation->getAttributes()[$rdn], null, LDAP_ESCAPE_DN);
}, $this->getRdnFromAttributes(array_keys($operation->getAttributes()))));
$operation->setDn($rdn.','.$this->resolveParameters(['container' => $location])['container']);
} | [
"protected",
"function",
"setDnToUse",
"(",
"AddOperation",
"$",
"operation",
")",
"{",
"// If the DN was explicitly set, don't do anything.",
"if",
"(",
"$",
"operation",
"->",
"getDn",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->"... | Builds the DN based off of the "name" attribute. The name attribute should be mapped to the "cn" attribute in
pretty much all cases except for creating an OU object. Then the "name" attribute should be mapped to "ou".
@param AddOperation $operation | [
"Builds",
"the",
"DN",
"based",
"off",
"of",
"the",
"name",
"attribute",
".",
"The",
"name",
"attribute",
"should",
"be",
"mapped",
"to",
"the",
"cn",
"attribute",
"in",
"pretty",
"much",
"all",
"cases",
"except",
"for",
"creating",
"an",
"OU",
"object",
... | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/OperationHydrator.php#L158-L176 | train |
ldaptools/ldaptools | src/LdapTools/Hydrator/OperationHydrator.php | OperationHydrator.getRdnFromAttributes | protected function getRdnFromAttributes(array $attributes) {
$rdn = [];
$rdnAttributes = array_map('strtolower', $this->schema->getRdn());
foreach ($rdnAttributes as $rdnAttribute) {
$rdnAttribute = $this->schema->getAttributeToLdap($rdnAttribute);
foreach ($attributes as $attribute) {
if (strtolower($attribute) === $rdnAttribute) {
$rdn[] = $attribute;
}
}
}
if (empty($rdn)) {
throw new LogicException(sprintf(
'To create a LDAP object you must use a RDN attribute from the schema. It is needed to form the base of'
. ' the distinguished name. Expected one, or more, of these attributes: %s',
implode(', ', $this->schema->getRdn())
));
}
return $rdn;
} | php | protected function getRdnFromAttributes(array $attributes) {
$rdn = [];
$rdnAttributes = array_map('strtolower', $this->schema->getRdn());
foreach ($rdnAttributes as $rdnAttribute) {
$rdnAttribute = $this->schema->getAttributeToLdap($rdnAttribute);
foreach ($attributes as $attribute) {
if (strtolower($attribute) === $rdnAttribute) {
$rdn[] = $attribute;
}
}
}
if (empty($rdn)) {
throw new LogicException(sprintf(
'To create a LDAP object you must use a RDN attribute from the schema. It is needed to form the base of'
. ' the distinguished name. Expected one, or more, of these attributes: %s',
implode(', ', $this->schema->getRdn())
));
}
return $rdn;
} | [
"protected",
"function",
"getRdnFromAttributes",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"rdn",
"=",
"[",
"]",
";",
"$",
"rdnAttributes",
"=",
"array_map",
"(",
"'strtolower'",
",",
"$",
"this",
"->",
"schema",
"->",
"getRdn",
"(",
")",
")",
";",... | Get the RDN attribute used to form the DN.
@param array $attributes The attribute names.
@return array | [
"Get",
"the",
"RDN",
"attribute",
"used",
"to",
"form",
"the",
"DN",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/OperationHydrator.php#L184-L205 | train |
ldaptools/ldaptools | src/LdapTools/Hydrator/OperationHydrator.php | OperationHydrator.setDefaultParameters | protected function setDefaultParameters()
{
if (!$this->connection) {
return;
}
$this->parameters['_domainname_'] = $this->connection->getConfig()->getDomainName();
$rootDse = $this->connection->getRootDse();
// Would this ever not be true? I'm unable to find any RFCs specifically regarding Root DSE structure.
if ($rootDse->has('defaultNamingContext')) {
$this->parameters['_defaultnamingcontext_'] = $rootDse->get('defaultNamingContext');
}
if ($rootDse->has('configurationNamingContext')) {
$this->parameters['_configurationnamingcontext_'] = $rootDse->get('configurationNamingContext');
}
} | php | protected function setDefaultParameters()
{
if (!$this->connection) {
return;
}
$this->parameters['_domainname_'] = $this->connection->getConfig()->getDomainName();
$rootDse = $this->connection->getRootDse();
// Would this ever not be true? I'm unable to find any RFCs specifically regarding Root DSE structure.
if ($rootDse->has('defaultNamingContext')) {
$this->parameters['_defaultnamingcontext_'] = $rootDse->get('defaultNamingContext');
}
if ($rootDse->has('configurationNamingContext')) {
$this->parameters['_configurationnamingcontext_'] = $rootDse->get('configurationNamingContext');
}
} | [
"protected",
"function",
"setDefaultParameters",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"connection",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"parameters",
"[",
"'_domainname_'",
"]",
"=",
"$",
"this",
"->",
"connection",
"->",
"getCo... | Set some default parameters based off the connection. | [
"Set",
"some",
"default",
"parameters",
"based",
"off",
"the",
"connection",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/OperationHydrator.php#L238-L253 | train |
ldaptools/ldaptools | src/LdapTools/Hydrator/OperationHydrator.php | OperationHydrator.filterAttributeValues | protected function filterAttributeValues(array $attributes)
{
return array_filter($attributes, function ($value) {
if (is_array($value) && empty($value)) {
return false;
}
return !($value === '' || $value === null);
});
} | php | protected function filterAttributeValues(array $attributes)
{
return array_filter($attributes, function ($value) {
if (is_array($value) && empty($value)) {
return false;
}
return !($value === '' || $value === null);
});
} | [
"protected",
"function",
"filterAttributeValues",
"(",
"array",
"$",
"attributes",
")",
"{",
"return",
"array_filter",
"(",
"$",
"attributes",
",",
"function",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"empty",
"(",
... | Remove empty strings and null values from attribute value arrays. This prevents errors when saving to LDAP and
these are present for some reason.
@param array $attributes
@return array | [
"Remove",
"empty",
"strings",
"and",
"null",
"values",
"from",
"attribute",
"value",
"arrays",
".",
"This",
"prevents",
"errors",
"when",
"saving",
"to",
"LDAP",
"and",
"these",
"are",
"present",
"for",
"some",
"reason",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/OperationHydrator.php#L271-L280 | train |
ldaptools/ldaptools | src/LdapTools/Connection/PageControl.php | PageControl.start | public function start($pageSize, $sizeLimit = 0)
{
if ($this->isEnabled) {
$this->cookie = '';
$this->pageSize = ($sizeLimit && $sizeLimit < $pageSize) ? $sizeLimit : $pageSize;
$this->sizeLimit = $sizeLimit;
}
} | php | public function start($pageSize, $sizeLimit = 0)
{
if ($this->isEnabled) {
$this->cookie = '';
$this->pageSize = ($sizeLimit && $sizeLimit < $pageSize) ? $sizeLimit : $pageSize;
$this->sizeLimit = $sizeLimit;
}
} | [
"public",
"function",
"start",
"(",
"$",
"pageSize",
",",
"$",
"sizeLimit",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEnabled",
")",
"{",
"$",
"this",
"->",
"cookie",
"=",
"''",
";",
"$",
"this",
"->",
"pageSize",
"=",
"(",
"$",
"sizeL... | Start a paging operation by setting up the cookie and the page size. Optionally set a size limit.
@param int $pageSize
@param int $sizeLimit
@throws LdapConnectionException | [
"Start",
"a",
"paging",
"operation",
"by",
"setting",
"up",
"the",
"cookie",
"and",
"the",
"page",
"size",
".",
"Optionally",
"set",
"a",
"size",
"limit",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/PageControl.php#L67-L74 | train |
ldaptools/ldaptools | src/LdapTools/Connection/PageControl.php | PageControl.end | public function end()
{
if ($this->isEnabled) {
$this->resetPagingControl();
$this->cookie = null;
$this->resultNumber = 0;
}
} | php | public function end()
{
if ($this->isEnabled) {
$this->resetPagingControl();
$this->cookie = null;
$this->resultNumber = 0;
}
} | [
"public",
"function",
"end",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEnabled",
")",
"{",
"$",
"this",
"->",
"resetPagingControl",
"(",
")",
";",
"$",
"this",
"->",
"cookie",
"=",
"null",
";",
"$",
"this",
"->",
"resultNumber",
"=",
"0",
";"... | End a paging operation.
@throws LdapConnectionException | [
"End",
"a",
"paging",
"operation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/PageControl.php#L81-L88 | train |
ldaptools/ldaptools | src/LdapTools/Connection/PageControl.php | PageControl.next | public function next()
{
if (!$this->isEnabled) {
return;
}
// If the size limit exceeds the page size, and the next page would exceed the limit, reduce the page size...
if ($this->sizeLimit && ($this->resultNumber + $this->pageSize) > $this->sizeLimit) {
$this->pageSize = $this->sizeLimit - $this->resultNumber;
}
if (!@ldap_control_paged_result($this->connection->getResource(), $this->pageSize, false, $this->cookie)) {
throw new LdapConnectionException(sprintf(
'Unable to enable paged results (%s): %s',
$this->connection->getLastErrorNumber(),
$this->connection->getLastError()
), $this->connection->getLastErrorNumber());
}
} | php | public function next()
{
if (!$this->isEnabled) {
return;
}
// If the size limit exceeds the page size, and the next page would exceed the limit, reduce the page size...
if ($this->sizeLimit && ($this->resultNumber + $this->pageSize) > $this->sizeLimit) {
$this->pageSize = $this->sizeLimit - $this->resultNumber;
}
if (!@ldap_control_paged_result($this->connection->getResource(), $this->pageSize, false, $this->cookie)) {
throw new LdapConnectionException(sprintf(
'Unable to enable paged results (%s): %s',
$this->connection->getLastErrorNumber(),
$this->connection->getLastError()
), $this->connection->getLastErrorNumber());
}
} | [
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEnabled",
")",
"{",
"return",
";",
"}",
"// If the size limit exceeds the page size, and the next page would exceed the limit, reduce the page size...",
"if",
"(",
"$",
"this",
"->",
"s... | Signifies to the connection to expect the next paged result with the current cookie and page size.
@throws LdapConnectionException | [
"Signifies",
"to",
"the",
"connection",
"to",
"expect",
"the",
"next",
"paged",
"result",
"with",
"the",
"current",
"cookie",
"and",
"page",
"size",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/PageControl.php#L95-L111 | train |
ldaptools/ldaptools | src/LdapTools/Connection/PageControl.php | PageControl.update | public function update($result)
{
if (!$this->isEnabled) {
return;
}
$this->resultNumber += $this->pageSize;
if (!@ldap_control_paged_result_response($this->connection->getResource(), $result, $this->cookie)) {
throw new LdapConnectionException(
sprintf('Unable to set paged results response: %s', $this->connection->getLastError())
);
}
} | php | public function update($result)
{
if (!$this->isEnabled) {
return;
}
$this->resultNumber += $this->pageSize;
if (!@ldap_control_paged_result_response($this->connection->getResource(), $result, $this->cookie)) {
throw new LdapConnectionException(
sprintf('Unable to set paged results response: %s', $this->connection->getLastError())
);
}
} | [
"public",
"function",
"update",
"(",
"$",
"result",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEnabled",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"resultNumber",
"+=",
"$",
"this",
"->",
"pageSize",
";",
"if",
"(",
"!",
"@",
"ldap_cont... | Updating the paging operation based on the result resource returned from a query.
@param resource $result
@throws LdapConnectionException | [
"Updating",
"the",
"paging",
"operation",
"based",
"on",
"the",
"result",
"resource",
"returned",
"from",
"a",
"query",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/PageControl.php#L119-L130 | train |
ldaptools/ldaptools | src/LdapTools/Connection/PageControl.php | PageControl.resetPagingControl | public function resetPagingControl()
{
// Per RFC 2696, to abandon a paged search you should send a size of 0 along with the cookie used in the search.
// However, testing this it doesn't seem to completely work. Perhaps a PHP bug?
if (!@ldap_control_paged_result($this->connection->getResource(), 0, false, $this->cookie)) {
throw new LdapConnectionException(sprintf(
'Unable to reset paged results control for read operation: %s',
$this->connection->getLastError()
));
}
} | php | public function resetPagingControl()
{
// Per RFC 2696, to abandon a paged search you should send a size of 0 along with the cookie used in the search.
// However, testing this it doesn't seem to completely work. Perhaps a PHP bug?
if (!@ldap_control_paged_result($this->connection->getResource(), 0, false, $this->cookie)) {
throw new LdapConnectionException(sprintf(
'Unable to reset paged results control for read operation: %s',
$this->connection->getLastError()
));
}
} | [
"public",
"function",
"resetPagingControl",
"(",
")",
"{",
"// Per RFC 2696, to abandon a paged search you should send a size of 0 along with the cookie used in the search.",
"// However, testing this it doesn't seem to completely work. Perhaps a PHP bug?",
"if",
"(",
"!",
"@",
"ldap_control... | Resets the paging control so that read operations work after a paging operation is used.
@throws LdapConnectionException | [
"Resets",
"the",
"paging",
"control",
"so",
"that",
"read",
"operations",
"work",
"after",
"a",
"paging",
"operation",
"is",
"used",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/PageControl.php#L137-L147 | train |
ldaptools/ldaptools | src/LdapTools/Query/Operator/BaseOperator.php | BaseOperator.getConvertedValue | public function getConvertedValue($alias = null)
{
if ($alias && isset($this->convertedAliasValue[$alias])) {
return $this->convertedAliasValue[$alias];
} else {
return $this->convertedValue;
}
} | php | public function getConvertedValue($alias = null)
{
if ($alias && isset($this->convertedAliasValue[$alias])) {
return $this->convertedAliasValue[$alias];
} else {
return $this->convertedValue;
}
} | [
"public",
"function",
"getConvertedValue",
"(",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"alias",
"&&",
"isset",
"(",
"$",
"this",
"->",
"convertedAliasValue",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"convertedAl... | Get the converted value.
@param string|null $alias
@return mixed | [
"Get",
"the",
"converted",
"value",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L124-L131 | train |
ldaptools/ldaptools | src/LdapTools/Query/Operator/BaseOperator.php | BaseOperator.setConvertedValue | public function setConvertedValue($value, $alias = null)
{
if ($alias) {
$this->convertedAliasValue[$alias] = $value;
} else {
$this->convertedValue = $value;
}
} | php | public function setConvertedValue($value, $alias = null)
{
if ($alias) {
$this->convertedAliasValue[$alias] = $value;
} else {
$this->convertedValue = $value;
}
} | [
"public",
"function",
"setConvertedValue",
"(",
"$",
"value",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"convertedAliasValue",
"[",
"$",
"alias",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"... | Set the converted value.
@param string|null $alias
@param mixed $value | [
"Set",
"the",
"converted",
"value",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L139-L146 | train |
ldaptools/ldaptools | src/LdapTools/Query/Operator/BaseOperator.php | BaseOperator.setAttribute | public function setAttribute($attribute)
{
if (strpos($attribute, '.') !== false) {
$pieces = explode('.', $attribute, 2);
$this->setAlias($pieces[0]);
$attribute = $pieces[1];
// If an alias was already set then this must be set back to null.
} else {
$this->alias = null;
}
$this->attribute = $attribute;
} | php | public function setAttribute($attribute)
{
if (strpos($attribute, '.') !== false) {
$pieces = explode('.', $attribute, 2);
$this->setAlias($pieces[0]);
$attribute = $pieces[1];
// If an alias was already set then this must be set back to null.
} else {
$this->alias = null;
}
$this->attribute = $attribute;
} | [
"public",
"function",
"setAttribute",
"(",
"$",
"attribute",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"attribute",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"pieces",
"=",
"explode",
"(",
"'.'",
",",
"$",
"attribute",
",",
"2",
")",
";",
"$",... | Set the attribute.
@param string $attribute | [
"Set",
"the",
"attribute",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L163-L174 | train |
ldaptools/ldaptools | src/LdapTools/Query/Operator/BaseOperator.php | BaseOperator.setOperatorSymbol | public function setOperatorSymbol($symbol)
{
if (!in_array($symbol, $this->validOperators)) {
throw new LdapQueryException(sprintf(
'Invalid operator symbol "%s". Valid operator symbols are: %s',
$symbol,
implode(', ', $this->validOperators)
));
}
$this->operatorSymbol = $symbol;
} | php | public function setOperatorSymbol($symbol)
{
if (!in_array($symbol, $this->validOperators)) {
throw new LdapQueryException(sprintf(
'Invalid operator symbol "%s". Valid operator symbols are: %s',
$symbol,
implode(', ', $this->validOperators)
));
}
$this->operatorSymbol = $symbol;
} | [
"public",
"function",
"setOperatorSymbol",
"(",
"$",
"symbol",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"symbol",
",",
"$",
"this",
"->",
"validOperators",
")",
")",
"{",
"throw",
"new",
"LdapQueryException",
"(",
"sprintf",
"(",
"'Invalid operator sy... | Set the operator symbol in use.
@param $symbol
@throws LdapQueryException | [
"Set",
"the",
"operator",
"symbol",
"in",
"use",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L222-L233 | train |
ldaptools/ldaptools | src/LdapTools/Query/Operator/BaseOperator.php | BaseOperator.setWasConverterUsed | public function setWasConverterUsed($value, $alias = null)
{
if ($alias) {
$this->converterAliasUsed[$alias] = (bool) $value;
} else {
$this->converterUsed = (bool) $value;
}
} | php | public function setWasConverterUsed($value, $alias = null)
{
if ($alias) {
$this->converterAliasUsed[$alias] = (bool) $value;
} else {
$this->converterUsed = (bool) $value;
}
} | [
"public",
"function",
"setWasConverterUsed",
"(",
"$",
"value",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"converterAliasUsed",
"[",
"$",
"alias",
"]",
"=",
"(",
"bool",
")",
"$",
"value",
";",
... | Set whether a converter was used or not.
@param bool $value
@param string|null $alias | [
"Set",
"whether",
"a",
"converter",
"was",
"used",
"or",
"not",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L281-L288 | train |
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",
"->",
"converterAl... | 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 | train |
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",
"(",
"$"... | 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 | train |
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 i... | 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 | train |
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",
"(",
")",... | 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 | train |
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",
"==",
"$",
"hydra... | 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 | train |
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",
"(",
... | 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 | train |
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",
"->",
"req... | 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 | train |
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",
"$",
... | 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 | train |
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",
"(",... | 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 | train |
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",
")",
";",
"... | 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 | train |
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 att... | 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 | train |
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",
")",
"]",
":",
"$"... | 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 | train |
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",
"]",
")",
")",
"{",
"$... | 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 | train |
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",
"->",
"c... | 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 | train |
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",
"->",... | 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 | train |
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",
"->",
"addAttri... | 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 | train |
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",
"->",
... | 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 | train |
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",
"->",
"g... | 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 | train |
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",
"... | 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 | train |
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'",
"]",
")",
... | 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"... | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/AttributeNameResolver.php#L112-L119 | train |
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",
",... | 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 | train |
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",
"(... | 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 | train |
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... | 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 | train |
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",
"(",
")",
")",
"{",
"i... | 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 | train |
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",
"(",
"... | 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 | train |
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",
"(",
... | 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 | train |
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",
"(",
"subs... | 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 | train |
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",
"->",... | 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 | train |
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",
"->"... | 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 | train |
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",
")",
... | 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 | train |
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 \"t... | 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 | train |
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 \"... | 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 | train |
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 si... | 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",
"... | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/LdifParser.php#L659-L678 | train |
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",
")",
")",... | 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 | train |
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",
... | 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",
... | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObject.php#L107-L110 | train |
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",
"=",
"$",
"thi... | 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 | train |
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",
"="... | 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 | train |
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"... | 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 | train |
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",
"... | 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 | train |
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",
"(... | 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 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.