strtolower() 공개 정적인 메소드

Make a string lower case.
public static strtolower ( string $value ) : string
$value string
리턴 string
예제 #1
0
 /**
  * If any attributes that were requested to be ordered by are not explicitly in the attribute selection, add them.
  *
  * @param array $attributes
  * @param null|string $alias
  * @return array
  */
 protected function mergeOrderByAttributes(array $attributes, $alias = null)
 {
     if (!$this->isWildCardSelection() && !empty($this->orderBy)) {
         $orderBy = $this->getAttributesForAlias(array_keys($this->orderBy), $alias);
         foreach ($orderBy as $attribute) {
             if (!in_array(MBString::strtolower($attribute), MBString::array_change_value_case($attributes))) {
                 $attributes[] = $attribute;
             }
         }
     }
     return $attributes;
 }
예제 #2
0
 /**
  * Given an array of attribute names, get all of the batches they have with their respective indexes
  *
  * @param array $attributes
  * @return array
  */
 protected function getBatchesForAttributes(array $attributes)
 {
     $batches = [];
     foreach ($this->batches as $index => $batch) {
         /** @var Batch $batch */
         if (in_array(MBString::strtolower($batch->getAttribute()), MBString::array_change_value_case($attributes))) {
             $batches[$index] = $batch;
         }
     }
     return $batches;
 }
예제 #3
0
 /**
  * Checks to make sure all required attributes are present.
  *
  * @param array $attributes
  */
 protected function validateAttributesToLdap(array $attributes)
 {
     if (!$this->schema) {
         return;
     }
     $missing = [];
     foreach ($this->schema->getRequiredAttributes() as $attribute) {
         if (!array_key_exists(MBString::strtolower($attribute), MBString::array_change_key_case($attributes))) {
             $missing[] = $attribute;
         }
     }
     if (!empty($missing)) {
         throw new LogicException(sprintf('The following required attributes are missing: %s', implode(', ', $missing)));
     }
 }
 /**
  * Get the value of an array key in a case-insensitive way.
  *
  * @param array $options
  * @param string $key
  */
 protected function getArrayValue(array $options, $key)
 {
     return MBString::array_change_key_case($options)[MBString::strtolower($key)];
 }
예제 #5
0
 /**
  * Check for a specific object type in the schema and validate it.
  *
  * @param array $schema
  * @param string $objectType
  * @return array
  * @throws SchemaParserException
  */
 protected function getObjectFromSchema(array $schema, $objectType)
 {
     $objectSchema = null;
     foreach ($schema['objects'] as $ldapObject) {
         if (array_key_exists('type', $ldapObject) && MBString::strtolower($ldapObject['type']) == MBString::strtolower($objectType)) {
             $objectSchema = $ldapObject;
         }
     }
     if (is_null($objectSchema)) {
         throw new SchemaParserException(sprintf('Cannot find object type "%s" in schema.', $objectType));
     }
     return $objectSchema;
 }
 /**
  * Check if the attribute value/meaning should be inverted. Provided as a convenience (ie. enabled) 
  *
  * @return bool
  */
 protected function shouldInvertValue()
 {
     return in_array(MBString::strtolower($this->getAttribute()), MBString::array_change_value_case($this->getOptions()['invert']));
 }
예제 #7
0
 /**
  * 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
  */
 protected function selectedButNotPartOfEntry($attribute, array $entry)
 {
     $lcAttribute = MBString::strtolower($attribute);
     $inSelectedAttributes = in_array($lcAttribute, MBString::array_change_value_case($this->selectedAttributes));
     $existsInEntry = array_key_exists($lcAttribute, MBString::array_change_key_case($entry));
     return $inSelectedAttributes && !$existsInEntry;
 }
예제 #8
0
 /**
  * Make sure that the current attribute has actually been defined.
  *
  * @throws AttributeConverterException
  */
 protected function validateCurrentAttribute()
 {
     if (!array_key_exists(MBString::strtolower($this->getAttribute()), MBString::array_change_key_case($this->getOptions()))) {
         throw new AttributeConverterException(sprintf('Attribute "%s" must be defined in the converter options.', $this->getAttribute()));
     }
 }
예제 #9
0
 /**
  * Whether a specific attribute is defined as multivalued or not.
  *
  * @param string $attribute
  * @return bool
  */
 public function isMultivaluedAttribute($attribute)
 {
     return in_array(MBString::strtolower($attribute), MBString::array_change_value_case($this->multivaluedAttributes));
 }
예제 #10
0
 /**
  * @param string $attribute
  * @return int
  */
 protected function getBitForAttribute($attribute)
 {
     $bit = MBString::array_change_key_case($this->getOptions()['typeMap'])[MBString::strtolower($attribute)];
     $bit = in_array($this->getAttribute(), $this->getOptions()['types']['type']) ? -1 * abs($bit) : $bit;
     return $bit;
 }
예제 #11
0
 /**
  * @param GPOLink[] $values
  * @param GPOLink[] $toRemove
  * @return GPOLink[]
  */
 protected function removeGPOLinksFromArray(array $values, array $toRemove)
 {
     foreach ($toRemove as $value) {
         $dn = $this->getGPOLinkDN($value);
         foreach ($values as $index => $originalValue) {
             if (MBString::strtolower($originalValue->getGpo()->get('dn')) == MBString::strtolower($dn)) {
                 unset($values[$index]);
                 break;
             }
         }
     }
     return $values;
 }
 /**
  * Modifies the existing list of addresses to set the default for a specific address type.
  *
  * @param string $defaultAddress
  */
 protected function modifyDefaultAddress($defaultAddress)
 {
     $values = is_array($this->getLastValue()) ? $this->getLastValue() : [$this->getLastValue()];
     $addressType = $this->getArrayValue($this->getOptions()['addressType'], $this->getAttribute());
     $isAddressInArray = in_array(MBString::strtolower($defaultAddress), MBString::array_change_value_case($values));
     $length = strlen($addressType);
     foreach ($values as $index => $address) {
         // If another address is already the default then it must be changed.
         if (substr($address, 0, $length) === strtoupper($addressType) && $address !== $defaultAddress) {
             $values[$index] = substr_replace($address, $addressType, 0, $length);
             // If the address is the one we are looking for but is not the default, then make it the default.
         } elseif ($isAddressInArray && MBString::strtolower($address) == MBString::strtolower($defaultAddress)) {
             $values[$index] = $defaultAddress;
         }
     }
     // It was not already an address in the array, and the other default would have been changed now.
     if (!in_array($defaultAddress, $values)) {
         $values[] = $defaultAddress;
     }
     $this->setLastValue($values);
 }
예제 #13
0
 /**
  * Takes all parameters (%username%, %someParameter%) within an attribute value and first checks for explicitly
  * set values for the parameter, then checks to see if the parameter name is a different attribute. If found it
  * takes the value either explicitly set or of the other attribute and replaces it within the original attribute.
  *
  * @param array $parameters All of the parameters found within the value.
  * @param array|string $original The original value for the attribute, containing the parameters.
  * @param array $attributes  All of the attributes being sent to LDAP.
  * @return string The attribute value after the passed parameters have been set.
  */
 protected function getValueForParameters(array $parameters, $original, array $attributes)
 {
     $wasArray = is_array($original);
     $original = $wasArray ? $original : [$original];
     foreach (array_keys($original) as $index) {
         foreach ($parameters as $parameter) {
             $value = '';
             // Explicitly set parameters values will take precedence
             if (array_key_exists(MBString::strtolower($parameter), MBString::array_change_key_case($this->parameters))) {
                 $value = array_change_key_case($this->parameters)[MBString::strtolower($parameter)];
             } elseif (array_key_exists(MBString::strtolower($parameter), MBString::array_change_key_case($attributes))) {
                 $value = MBString::array_change_key_case($attributes)[MBString::strtolower($parameter)];
             }
             if (is_array($value) && count($value) !== 1) {
                 throw new InvalidArgumentException(sprintf('Cannot use a multi-valued attribute "%s" as a parameter.', $parameter));
             }
             $value = is_array($value) && count($value) == 1 ? reset($value) : $value;
             $original[$index] = preg_replace("/" . self::PARAM_MARKER . $parameter . self::PARAM_MARKER . "/", $value, $original[$index]);
         }
     }
     return $wasArray ? $original : $original[0];
 }
예제 #14
0
 /**
  * Determine how to get the value for the attribute from the LDAP entry being compared, and return that value.
  *
  * @param array|LdapObject $entry
  * @param string $attribute
  * @return mixed
  */
 protected function getComparisonValue($entry, $attribute)
 {
     $alias = null;
     if (!empty($this->aliases)) {
         list($alias, $attribute) = LdapUtilities::getAliasAndAttribute($attribute);
     }
     $value = '';
     if (is_array($entry) && isset($entry[$attribute])) {
         $value = $entry[$attribute];
         // Be forgiving if they are hydrating to an array and the case of the attribute was not correct.
     } elseif (is_array($entry) && array_key_exists(MBString::strtolower($attribute), MBString::array_change_key_case($entry))) {
         $value = MBString::array_change_key_case($entry)[MBString::strtolower($attribute)];
         // Only get the value if there is no alias requested, or if an alias was requested the object type must match the alias.
     } elseif ($entry instanceof LdapObject && (!$alias || $entry->isType($this->aliases[$alias]->getObjectType())) && $entry->has($attribute)) {
         $value = $entry->get($attribute);
     }
     // How to handle multi-valued attributes? This will at least prevent errors, but may not be accurate.
     $value = is_array($value) ? reset($value) : $value;
     return $this->convertValueToString($value);
 }
예제 #15
0
 /**
  * @param string $propName
  * @return TSProperty
  */
 protected function getTsPropObj($propName)
 {
     return MBString::array_change_key_case($this->tsProperty)[MBString::strtolower($propName)];
 }
예제 #16
0
 /**
  * Performs the logic for switching the LDAP server connection.
  *
  * @param string|null $currentServer The server we are currently on.
  * @param string|null $wantedServer The server we want the connection to be on.
  * @param LdapOperationInterface $operation
  */
 protected function switchServerIfNeeded($currentServer, $wantedServer, LdapOperationInterface $operation)
 {
     if ($operation instanceof AuthenticationOperation || MBString::strtolower($currentServer) == MBString::strtolower($wantedServer)) {
         return;
     }
     if ($this->connection->isBound()) {
         $this->connection->close();
     }
     $this->connection->connect(null, null, false, $wantedServer);
 }
예제 #17
0
 /**
  * @return bool
  */
 protected function expectsBool()
 {
     return MBString::strtolower($this->getOptions()['bool']) == MBString::strtolower($this->getAttribute());
 }
예제 #18
0
 /**
  * Form the "name" string that the cache uses to refer to this item.
  *
  * @param string $itemType
  * @param string $itemName
  * @return string
  */
 protected function getCacheName($itemType, $itemName)
 {
     return MBString::strtolower($this->cachePrefix . '/' . $itemType . '/' . $itemName);
 }
예제 #19
0
 /**
  * Get the value of an attribute. An attribute with multiple values will return an array of values.
  *
  * @param string $attribute
  * @return mixed
  */
 public function get($attribute)
 {
     if ($this->has($attribute)) {
         return MBString::array_change_key_case($this->attributes)[MBString::strtolower($attribute)];
     } else {
         throw new InvalidArgumentException(sprintf('Attribute "%s" is not defined for this LDAP object.', $attribute));
     }
 }