/** * Returns a single URL using a key * with an optionally suffixed realtive URL * * @param string $key Key for the target URL * @param string $relative_url Optional relative URL * @return string URL */ public function get($key, $relative_url = null) { // Get URL without trailing slash $url = $this->__urls->get($key); // Concatenate relative URL if ($relative_url) { $url .= '/' . ltrim($relative_url, '/'); } return $url; }
/** * Returns a single path using a key * with an optionally suffixed realtive path * * @param string $key Key for the target path * @param string $relative_path Optional relative path * @return string path */ public function get($key, $relative_path = null) { // Get path without trailing slash $path = $this->__paths->get($key); // Concatenate relative URL if ($relative_path) { $path .= '/' . ltrim($relative_path, '/'); } return $path; }
/** * Gets data with target key * * @param string $key Key to get data from * @param boolean $is_single False if we assume there is an array of values, true if only a single value * @return mixed Data contained in target key */ public function get($key, $is_single = false) { // Get data from container $data = $this->__data->get($key); // If array and single item is requested, try to unserialize it if ($data && is_array($data) && $is_single) { // Get first item $data = isset($data[0]) ? maybe_unserialize($data[0]) : ''; } elseif (is_array($data) && !array_filter($data) && $is_single) { $data = $is_single ? '' : array(); } // Return data return $data; }
/** * Calls the target plugin using its key * * @param string $name Key that identifies the target plugin * @param array $args Arguments to pass to target plugin * @return mixed New instance of target plugin class */ public function __call($name, $args) { $className = $this->__plugins->get($name); if (class_exists($className)) { return call_user_func_array([new \ReflectionClass($className), 'newInstance'], $args); } }
/** * Returns the current environment * * @return Ponticlaro\Bebop\Env The current environment */ public function getCurrent() { $envs = $this->__environments->getAll(); foreach ($envs as $key => $env) { if ($env->isCurrent()) { return $env; } } return $this->__environments->get('development'); }