/** * Compile Blade statements that start with "@". * * @param string $value * @return mixed */ protected function compileStatements($value) { $callback = function ($match) { if (method_exists($this, $method = 'compile' . ucfirst($match[1]))) { $match[0] = $this->{$method}(Arr::get(3, $match)); } elseif (isset($this->customDirectives[$match[1]])) { $match[0] = call_user_func($this->customDirectives[$match[1]], Arr::get(3, $match)); } return isset($match[3]) ? $match[0] : $match[0] . $match[2]; }; return preg_replace_callback('/\\B@(\\w+)([ \\t]*)(\\( ( (?>[^()]+) | (?3) )* \\))?/x', $callback, $value); }
/** * Remove values from an array that match entries marked as immutable in the collection. * * @param $vars * * @return mixed */ protected function filter_immutables($vars) { $candidates = []; foreach ($vars as $key => $value) { if (array_key_exists($key, $this->read_only)) { $candidates[] = $key; } } Arr::forget($candidates, $vars); return $vars; }
/** * Locate a value by `$key`, return `$default` if not found. * * @param string|array $key * @param mixed $default * * @return mixed */ function search($key, $default = NULL) { return Arr::search($key, $this->storage, $default); }
/** * Get the Rackspace Cloud Files container. * * @param \OpenCloud\Rackspace $client * @param array $config * * @return \OpenCloud\ObjectStore\Resource\Container */ protected function getRackspaceContainer(Rackspace $client, array $config) { $urlType = Arr::get($config, 'url_type'); $store = $client->objectStoreService('cloudFiles', $config['region'], $urlType); return $store->getContainer($config['container']); }
/** * Merges an array of symbols with the container. * Note: This method strips immutable variables from the symbols array before merging. * * @param $symbols * * @return $this|void */ public function merge($symbols) { $symbols = $this->normalize($symbols); # strip immutable symbols as they are, well, immutable. $symbols = $this->filter_immutables($symbols); if (!Arr::is_assoc($symbols)) { $symbols = Arr::transform_array_hash($symbols); } $this->storage = array_merge($this->storage, $symbols); return $this; }
/** * Merges any number of arrays of any dimensions, the later overwriting * previous keys, unless the key is numeric, in which case, duplicated * values will not be added. The arrays to be merged are passed as * arguments to the function. * * @package SupportLoader * @module arrays * * @param null $key * @param null $value * * @return array - Resulting array, once all have been merged */ static function merge_recursive_replace($key, $value) { // Holds all the arrays passed $params = func_get_args(); // First array is used as the base, everything else overwrites on it $return = array_shift($params); // Merge all arrays on the first array foreach ($params as $array) { foreach ($array as $key => $value) { if (isset($return[$key]) && is_array($value) && is_array($return[$key])) { $return[$key] = Arr::merge_recursive_replace($return[$key], $value); } else { $return[$key] = $value; } } } return $return; }
/** * Merge a single key, value pair. * * @param string $name * @param null $value * * @return static */ public function with($name, $value = NULL) { Arr::is_assoc($name) ? $this->merge($name) : ($this->storage[$name] = $value); }