/** * Overloading returning processed template. * @param $template * @return void */ public function render($template) { if (is_readable($templateFile = APP_DIR . "/templates/{$template}.phtml")) { extract($this->values, EXTR_SKIP); include $templateFile; die; } else { Soprano::exception('Template not found!'); } }
/** * Overload all calls to the adapter and redir them to the @Object contained. * __callStatic() only in PHP >= 5.3.0 * @param $method * @param $parameters * @return */ public function __call($method, $parameters) { try { $method = new ReflectionMethod($this->modelObject, $method); if ($method->getNumberOfRequiredParameters() > 0) { return $method->invokeArgs($this->modelObject, $parameters); } else { return $method->invoke($this->modelObject, null); } } catch (ReflectionException $e) { Soprano::exception($e->getMessage()); } }
/** * Make a guess. * @param $letter * @return bool true if we have won */ public function guess($letter) { if (empty($this->guessed)) { Soprano::exception('You need to create a new game first!'); } foreach ($this->guessed as &$g) { // if we have a match and are not guessing the guessed again... if (key($g) == $letter && current($g) == '_') { $g = array($letter => $letter); $this->left--; } } $this->removeLetter(strtolower($letter)); $this->round++; return $this->left <= 0; }
/** * Build a model object or its stateful adapter. * @static * @param $model * @param $state * @return Object */ public static function build($model, $state = null) { $stateFile = APP_DIR . '/states/' . ucfirst($model) . 'State.php'; // is model stateful? if (is_readable($stateFile)) { include_once $stateFile; // name convention $model .= 'State'; // build it return new $model($state); } else { // return a new vanilla model if (is_readable($modelFile = APP_DIR . "/models/{$model}Model.php")) { include_once $modelFile; return new $model(); } else { Soprano::exception('Model not found!'); } } }