示例#1
0
 /**
  * Array get
  *
  * @param array $array
  * @param  $key
  * @param null $default
  * @return mixed
  * @throws null
  */
 function array_get(array $array, $key, $default = null)
 {
     if ($default instanceof \Exception) {
         throw $default;
     }
     if (is_null($key)) {
         return $array;
     }
     if (isset($array[$key])) {
         return $array[$key];
     }
     foreach (explode('.', $key) as $segment) {
         if (!is_array($array) || !array_key_exists($segment, $array)) {
             return resolve_value($default);
         }
         $array = $array[$segment];
     }
     return $array;
 }
 public function getCustomAttribute($key, $default = null)
 {
     return array_get($this->attributes, $key, resolve_value($default));
 }