/** * 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); } }
/** * Checks if this is the current environment * * @return boolean True if listed in this environment, false otherwise */ public function isCurrent() { // Use Hosts to determine current environment if ($this->__hosts->count() >= 1) { return $this->__hosts->hasValue($_SERVER['SERVER_NAME']); } elseif (getenv('APP_ENV') && getenv('APP_ENV') == $this->__key) { return true; } return false; }
/** * 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'); }
/** * Returns all urls * * @return array */ public function getAll() { return $this->__urls->getAll(); }
/** * Returns all paths * * @return array */ public function getAll() { return $this->__paths->getAll(); }