diff --git a/core/c/controller.php b/core/c/controller.php index b53792f..ed90bc6 100644 --- a/core/c/controller.php +++ b/core/c/controller.php @@ -1,5 +1,7 @@ _setConfig(Config::getInstance()->getConfig()); - } + protected function __construct() + { + $this->_setConfig(Config::getInstance()->getConfig()); + } - public static function getInstance(): View - { - $className = get_called_class(); - if( self::$_instance == null ) - { - self::$_instance = new $className(); + public static function getInstance(): View + { + $className = get_called_class(); + if( self::$_instance == null ) + { + self::$_instance = new $className(); } - return self::$_instance; - } + return self::$_instance; + } - /** - * @return array - */ - protected function getConfig() - { - return $this->_config; - } + /** + * @return array + */ + protected function getConfig() + { + return $this->_config; + } - /** - * @param array $config - */ - protected function _setConfig( $config ) - { - $this->_config = $config; - } + /** + * @param array $config + */ + protected function _setConfig( $config ) + { + $this->_config = $config; + } - /** - * @return string - */ - public function getController() - { - return $this->_controller; - } + /** + * @return string + */ + public function getController() + { + return $this->_controller; + } - /** - * @param string $controller - */ - protected function setController( $controller ) - { - $this->_controller = $controller; - } - - /** - * @param $template - * @param $page - */ - public function action( $template, $page ) - { - $this->_setCurrent( $this->getNext() ); - $this->_setNext( $page ); - $template->display( $this->getNext() ); - } + /** + * @param string $controller + */ + protected function setController( $controller ) + { + $this->_controller = $controller; + } - public function varname( $template, $varname = array() ) - { - if(is_array($varname)) - { - $template->assign($varname); - } - } + /** + * @param $template + * @param $page + */ + public function action( $template, $page ) + { + $this->_setCurrent( $this->getNext() ); + $this->_setNext( $page ); + $template->display( $this->getNext() ); + } - /** - * @return array - */ - protected function getCurrent() - { - return $this->_current; - } + public function varname( $template, $varname = array() ) + { + if(is_array($varname)) + { + $template->assign($varname); + } + } - /** - * @param array $current - */ - private function _setCurrent( $current ) - { - $this->_current = $current; - } + /** + * @return array + */ + protected function getCurrent() + { + return $this->_current; + } - /** - * @return array - */ - protected function getNext() - { - return $this->_next; - } + /** + * @param array $current + */ + private function _setCurrent( $current ) + { + $this->_current = $current; + } - /** - * @param array $next - */ - public function _setNext( $next ) - { - $this->_next = $next; - } + /** + * @return array + */ + protected function getNext() + { + return $this->_next; + } - /** - * @return array - */ - public function getPost() - { - return $_POST; - } + /** + * @param array $next + */ + public function _setNext( $next ) + { + $this->_next = $next; + } - /** - * @return array - */ - public function getGet() - { - return $_GET; - } + /** + * @param string $param + * @param bool $params + * @return string|null + */ + public function getPost( string $param, bool $params = false ) :mixed + { + if($param!="") + { + return $_POST[$param]; + } + elseif($params) + { + return $_POST; + } + } - /** - * @return array - */ - public function getRequest() - { - return $_REQUEST; - } + /** + * @param string $param + * @param bool $params + * @return string|null + */ + public function getGet( string $param, bool $params = false ) :?string + { + if($param!="") + { + return $_GET[$param]; + } + elseif($params) + { + return $_GET; + } + } - /** - * @return mixed - */ - public function getServer() - { - return $_SERVER; - } + /** + * @param string $param + * @param bool $params + * @return mixed + */ + public function getRequest( string $param, bool $params = false ) :?string + { + if($param!="") + { + return $_REQUEST[$param]; + } + elseif($params) + { + return $_REQUEST; + } + } + + /** + * @param string $param + * @param bool $params + * @return string|null + */ + public function getServer( string $param, bool $params = false ) :?string + { + if($param!="") + { + return $_SERVER[$param]; + } + elseif($params) + { + return $_SERVER; + } + } } \ No newline at end of file