/**
  * {@inheritdoc}
  */
 public function castToArray()
 {
     return Arr::arToArray($this->model);
 }
Beispiel #2
0
 /**
  * Convert this implementation object to array.
  *
  * @param mixed $attributes Something you want to convert to array.
  *
  * @return array
  *
  * @see Arr::arToArray()
  */
 public function toArray($attributes = null)
 {
     if ($this->jsonAble === null) {
         $jsonAble = array();
         if ($attributes === null) {
             $attributes = $this->attributes;
         }
         foreach ($attributes as $key => $value) {
             if ($value instanceof CActiveRecord) {
                 $jsonAble[$key] = Arr::arToArray($value);
             } elseif ($value instanceof Arrayable) {
                 $jsonAble[$key] = $value->castToArray();
             } elseif (is_object($value)) {
                 $jsonAble[$key] = (array) $value;
             } elseif (is_array($value)) {
                 $jsonAble[$key] = $this->toArray($value);
             } else {
                 $jsonAble[$key] = $value;
             }
         }
         $this->jsonAble = $jsonAble;
     }
     return $this->jsonAble;
 }
Beispiel #3
0
 /**
  * Replace your array value.
  *
  * ```php
  * $header = [
  *     ':type_address',
  *     ':type_citizenship',
  *     ':type_city',
  *     ':type_country' ]
  *
  * Arr::replaceValue($header, ':type_')
  *
  * // Will produce:
  *
  * $header = [
  *     'address',
  *     'citizenship',
  *     'city',
  *     'country' ]
  * ```
  *
  * @param array           $input
  * @param string|callable $search
  * @param string          $replacement
  *
  * @return array
  *
  * @author Krisan Alfa Timur <*****@*****.**>
  */
 function array_replace_value(array $input, $search, $replacement = '')
 {
     return Arr::replaceValue($input, $search, $replacement);
 }
Beispiel #4
0
 /**
  * Pulls an item from the collection.
  *
  * @param mixed $key
  * @param mixed $default
  *
  * @return mixed
  */
 public function pull($key, $default = null)
 {
     return Arr::pull($this->items, $key, $default);
 }