array_change_value_case() публичный статический Метод

Change the values in an array to lower-case values.
public static array_change_value_case ( array $values ) : array
$values array
Результат array
Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function fromLdap($value)
 {
     $ldapType = ['Unknown'];
     $value = MBString::array_change_value_case($value);
     foreach ($this->getOptions() as $type => $classes) {
         if (MBString::array_change_value_case($classes) == $value) {
             $ldapType = [$type];
             break;
         }
     }
     return $ldapType;
 }
Пример #2
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;
 }
Пример #3
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;
 }
 /**
  * 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']));
 }
Пример #5
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));
 }
 /**
  * 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);
 }
Пример #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;
 }