From af02bc58b2fe031619180ddc0216ab12e7a95f36 Mon Sep 17 00:00:00 2001 From: John Le Drew Date: Thu, 15 Oct 2009 08:22:04 +0100 Subject: [PATCH] More comments... --- source/lib/simplicity/archive/archive.php | 1 + source/lib/simplicity/config/backend.php | 2 + source/lib/simplicity/config/config.php | 2 +- source/lib/simplicity/config/drivers/array.php | 2 +- source/lib/simplicity/controller/controller.php | 2 +- source/lib/simplicity/data/db/backends/pdo.php | 2 +- .../lib/simplicity/data/db/backends/pdo_mysql.php | 3 +- .../lib/simplicity/data/db/backends/pdo_sqlite.php | 2 +- source/lib/simplicity/data/meta/backend.php | 2 +- source/lib/simplicity/data/meta/backends/mysql.php | 2 +- .../lib/simplicity/data/meta/backends/sqlite.php | 2 +- .../lib/simplicity/data/table/table_iterator.php | 2 +- .../simplicity/data/table/table_iterator_group.php | 2 +- source/lib/simplicity/data/table/type.php | 2 +- source/lib/simplicity/data/table/types/date.php | 2 +- source/lib/simplicity/dispatcher/dispatcher.php | 3 +- source/lib/simplicity/environment/environment.php | 3 +- source/lib/simplicity/error/error.php | 15 +++ source/lib/simplicity/error/exception.php | 52 ++++++++- source/lib/simplicity/error/http_exception.php | 20 +++- source/lib/simplicity/meta/class_meta.php | 78 ++++++++++++++ source/lib/simplicity/meta/meta_tag.php | 29 ++++- source/lib/simplicity/meta/method_meta.php | 21 +++- source/lib/simplicity/meta/tags/license.php | 13 ++- source/lib/simplicity/meta/tags/link.php | 16 ++- source/lib/simplicity/meta/tags/smp_children.php | 17 ++- source/lib/simplicity/meta/tags/smp_depends.php | 17 ++- source/lib/simplicity/module/module.php | 2 +- source/lib/simplicity/module/static.php | 2 +- source/lib/simplicity/pluggable/pluggable.php | 1 + source/lib/simplicity/request/request.php | 59 +++++++++- source/lib/simplicity/response/response.php | 119 ++++++++++++++------- 32 files changed, 424 insertions(+), 73 deletions(-) diff --git a/source/lib/simplicity/archive/archive.php b/source/lib/simplicity/archive/archive.php index b1de7d5..54e1526 100644 --- a/source/lib/simplicity/archive/archive.php +++ b/source/lib/simplicity/archive/archive.php @@ -11,6 +11,7 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha * + * @smp_core */ class smp_Archive { diff --git a/source/lib/simplicity/config/backend.php b/source/lib/simplicity/config/backend.php index 313f26b..d206239 100644 --- a/source/lib/simplicity/config/backend.php +++ b/source/lib/simplicity/config/backend.php @@ -10,6 +10,8 @@ * @version 2.0.0-alpha * * @see smp_Config + * + * @smp_core */ interface smp_ConfigBackend { diff --git a/source/lib/simplicity/config/config.php b/source/lib/simplicity/config/config.php index 4913c18..4174505 100644 --- a/source/lib/simplicity/config/config.php +++ b/source/lib/simplicity/config/config.php @@ -11,7 +11,7 @@ * @version 2.0.0-alpha * * @smp_children smp_ConfigBackend - * + * @smp_core */ class smp_Config extends smp_Pluggable { diff --git a/source/lib/simplicity/config/drivers/array.php b/source/lib/simplicity/config/drivers/array.php index bf5cc96..239ea7f 100644 --- a/source/lib/simplicity/config/drivers/array.php +++ b/source/lib/simplicity/config/drivers/array.php @@ -9,7 +9,7 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core */ class smp_ConfigBackendArray implements smp_ConfigBackend { diff --git a/source/lib/simplicity/controller/controller.php b/source/lib/simplicity/controller/controller.php index 3ac8e99..3535504 100644 --- a/source/lib/simplicity/controller/controller.php +++ b/source/lib/simplicity/controller/controller.php @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core */ class smp_ControllerModule extends smp_Module { diff --git a/source/lib/simplicity/data/db/backends/pdo.php b/source/lib/simplicity/data/db/backends/pdo.php index ed2eb39..75f7998 100644 --- a/source/lib/simplicity/data/db/backends/pdo.php +++ b/source/lib/simplicity/data/db/backends/pdo.php @@ -10,7 +10,7 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core */ abstract class smp_PdoDbBackend implements smp_DbBackend { diff --git a/source/lib/simplicity/data/db/backends/pdo_mysql.php b/source/lib/simplicity/data/db/backends/pdo_mysql.php index cc6f3cb..f5ed970 100644 --- a/source/lib/simplicity/data/db/backends/pdo_mysql.php +++ b/source/lib/simplicity/data/db/backends/pdo_mysql.php @@ -10,7 +10,8 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core + * */ class smp_PdoMysqlDbBackend extends smp_PdoDbBackend { diff --git a/source/lib/simplicity/data/db/backends/pdo_sqlite.php b/source/lib/simplicity/data/db/backends/pdo_sqlite.php index 664ac01..3a2498d 100644 --- a/source/lib/simplicity/data/db/backends/pdo_sqlite.php +++ b/source/lib/simplicity/data/db/backends/pdo_sqlite.php @@ -10,7 +10,7 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core */ class smp_PdoSqliteDbBackend extends smp_PdoDbBackend { diff --git a/source/lib/simplicity/data/meta/backend.php b/source/lib/simplicity/data/meta/backend.php index 158e46f..cb34b96 100644 --- a/source/lib/simplicity/data/meta/backend.php +++ b/source/lib/simplicity/data/meta/backend.php @@ -9,7 +9,7 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core */ abstract class smp_MetaBackend { diff --git a/source/lib/simplicity/data/meta/backends/mysql.php b/source/lib/simplicity/data/meta/backends/mysql.php index 189822e..e732d36 100644 --- a/source/lib/simplicity/data/meta/backends/mysql.php +++ b/source/lib/simplicity/data/meta/backends/mysql.php @@ -9,7 +9,7 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core */ class smp_MetaBackendMysql extends smp_MetaBackend { diff --git a/source/lib/simplicity/data/meta/backends/sqlite.php b/source/lib/simplicity/data/meta/backends/sqlite.php index 2ea1003..cf72f5d 100644 --- a/source/lib/simplicity/data/meta/backends/sqlite.php +++ b/source/lib/simplicity/data/meta/backends/sqlite.php @@ -9,7 +9,7 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core */ class smp_MetaBackendSqlite extends smp_MetaBackend { diff --git a/source/lib/simplicity/data/table/table_iterator.php b/source/lib/simplicity/data/table/table_iterator.php index 00d4800..33ae0e9 100644 --- a/source/lib/simplicity/data/table/table_iterator.php +++ b/source/lib/simplicity/data/table/table_iterator.php @@ -9,7 +9,7 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core */ class smp_DataTableIterator implements Iterator,Countable { diff --git a/source/lib/simplicity/data/table/table_iterator_group.php b/source/lib/simplicity/data/table/table_iterator_group.php index 8ff7754..d0a238c 100644 --- a/source/lib/simplicity/data/table/table_iterator_group.php +++ b/source/lib/simplicity/data/table/table_iterator_group.php @@ -9,7 +9,7 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core */ class smp_DataTableIteratorGroup implements Iterator,Countable { diff --git a/source/lib/simplicity/data/table/type.php b/source/lib/simplicity/data/table/type.php index 4821aef..d339bce 100644 --- a/source/lib/simplicity/data/table/type.php +++ b/source/lib/simplicity/data/table/type.php @@ -9,7 +9,7 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core */ interface smp_DataTableType { diff --git a/source/lib/simplicity/data/table/types/date.php b/source/lib/simplicity/data/table/types/date.php index 831ff44..de84111 100644 --- a/source/lib/simplicity/data/table/types/date.php +++ b/source/lib/simplicity/data/table/types/date.php @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core */ class smp_DateDataTableType implements smp_DataTableType { diff --git a/source/lib/simplicity/dispatcher/dispatcher.php b/source/lib/simplicity/dispatcher/dispatcher.php index 7d0e06e..4fc368c 100644 --- a/source/lib/simplicity/dispatcher/dispatcher.php +++ b/source/lib/simplicity/dispatcher/dispatcher.php @@ -8,7 +8,8 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core + * */ class smp_DispatcherModule extends smp_Module { diff --git a/source/lib/simplicity/environment/environment.php b/source/lib/simplicity/environment/environment.php index a7a4e10..0c56c05 100644 --- a/source/lib/simplicity/environment/environment.php +++ b/source/lib/simplicity/environment/environment.php @@ -8,7 +8,8 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core + * */ class smp_Enviroment { diff --git a/source/lib/simplicity/error/error.php b/source/lib/simplicity/error/error.php index 8caab5f..c64af26 100644 --- a/source/lib/simplicity/error/error.php +++ b/source/lib/simplicity/error/error.php @@ -15,6 +15,9 @@ class smp_ErrorModule extends smp_Module { private $_handled = false; + /** + * @inherited + */ protected function init() { $this->setDefault('view_path',dirname(__FILE__).DS.'templates'.DS); @@ -26,6 +29,9 @@ class smp_ErrorModule extends smp_Module )); } + /** + * @inherited + */ public function exec($args=array()) { ini_set('display_errors',1); @@ -35,6 +41,9 @@ class smp_ErrorModule extends smp_Module set_exception_handler(array($this,'exception')); } + /** + * @internal + */ public function error($errno,$errstr,$errfile,$errline) { restore_error_handler(); @@ -42,6 +51,9 @@ class smp_ErrorModule extends smp_Module throw new smp_Exception($errstr,$errline,$errno,$errfile); } + /** + * @internal + */ public function shutdown() { restore_error_handler(); @@ -57,6 +69,9 @@ class smp_ErrorModule extends smp_Module } } + /** + * @internal + */ public function exception(Exception $e) { restore_error_handler(); diff --git a/source/lib/simplicity/error/exception.php b/source/lib/simplicity/error/exception.php index 1ac8b77..915fae1 100644 --- a/source/lib/simplicity/error/exception.php +++ b/source/lib/simplicity/error/exception.php @@ -1,32 +1,74 @@ + * @copyright Copyright (c) 2009, John Le Drew + * @license http://www.opensource.org/licenses/mit-license.php MIT License + * @version 2.0.0-alpha + * + * @smp_core + */ class smp_Exception extends Exception { private $_context = array(); private $_headers = array(); - public function __construct($msg,$errline=null,$errno=null,$errfile=null) + /** + * Constructor + * + * Create a new exception providing the error $msg, $line number, error $code and $file. + * + * @param $msg string + * @param $line int + * @param $code int + * @param $file string + */ + public function __construct($msg,$line=null,$code=null,$file=null) { parent::__construct($msg); - $this->file = $errfile; - $this->line = $errline; - $this->code = $errno; + $this->file = $file; + $this->line = $line; + $this->code = $code; $this->processContext(); $this->processHeaders(); } + /** + * getContext + * + * Retrieve the context of this exception. + * + * @return array + */ public function getContext() { return $this->_context; } + /** + * getHeaders + * + * Retrieve the request and response headers of this exception. + * + * @return array + */ public function getHeaders() { return $this->_headers; } + /** + * getSafeTrace + * + * Return the backtrace with each argument run through print_r for easy display. + * + * @return array + */ public function getSafeTrace() { $trace = $this->getTrace(); diff --git a/source/lib/simplicity/error/http_exception.php b/source/lib/simplicity/error/http_exception.php index 4f96366..07d9b52 100644 --- a/source/lib/simplicity/error/http_exception.php +++ b/source/lib/simplicity/error/http_exception.php @@ -1,5 +1,16 @@ + * @copyright Copyright (c) 2009, John Le Drew + * @license http://www.opensource.org/licenses/mit-license.php MIT License + * @version 2.0.0-alpha + * + * @smp_core + */ class smp_HttpException extends smp_Exception { private $_status_codes = array( @@ -45,6 +56,13 @@ class smp_HttpException extends smp_Exception 505 => 'HTTP Version Not Supported' ); + /** + * Constructor + * + * Creates a new smp_HttpException, pass in the HTTP error code to create the exception. + * + * @param $code int + */ public function __construct($code) { $code = isset($this->_status_codes[$code]) ? $code : 500; diff --git a/source/lib/simplicity/meta/class_meta.php b/source/lib/simplicity/meta/class_meta.php index ba01c97..7eecb06 100644 --- a/source/lib/simplicity/meta/class_meta.php +++ b/source/lib/simplicity/meta/class_meta.php @@ -1,4 +1,17 @@ + * @copyright Copyright (c) 2009, John Le Drew + * @license http://www.opensource.org/licenses/mit-license.php MIT License + * @version 2.0.0-alpha + * + * @smp_children smp_MetaTag + * @smp_core + */ class smp_ClassMetaData extends smp_Pluggable { private $_comments; @@ -12,6 +25,12 @@ class smp_ClassMetaData extends smp_Pluggable { private $_reflection; + /** + * Constructor + * + * Create a new smp_ClassMetaData instance, your should pass the class name as the first parameter. + * + */ final public function __construct() { $this->createExtensionPoint('smp_MetaTag'); @@ -22,6 +41,14 @@ class smp_ClassMetaData extends smp_Pluggable { $this->_reflection = $this->getReflector(); } + /** + * init + * + * Initialize the class meta data. + * + * @param $args + * @return boolean + */ protected function init($args) { if (!smp_Tapped::getInstance()->exists($args[0])) return false; @@ -31,33 +58,76 @@ class smp_ClassMetaData extends smp_Pluggable { return true; } + /** + * getReflector + * + * Return the ReflectionClass instance for the given entity. + * + * @return ReflectionClass + */ public function getReflector() { $ref = new ReflectionClass($this->_class); return $ref; } + /** + * getTag + * + * Retrieve the value of the given tag $name. + * + * @param $name string + */ final public function getTag($name) { if (!$this->_parsed) $this->parse(); return isset($this->_tags[$name]) ? $this->_tags[$name] : false; } + /** + * getTags + * + * Retrieve an array of tags on a class + * + * @return array + */ final public function getTags() { if (!$this->_parsed) $this->parse(); return $this->_tags; } + /** + * getTitle + * + * Retrieve the doc comment title. + * + * @return string + */ final public function getTitle() { if (!$this->_parsed) $this->parse(); return $this->_title; } + /** + * getDescription + * + * Retrieve the doc comment description. + * + * @return string + */ final public function getDescription() { if (!$this->_parsed) $this->parse(); return $this->_description; } + /** + * getMethods + * + * Retrieve an array of methods in the class. Pass in true as the first parameter to include private methods. + * + * @param $include_private boolean + * @return array + */ final public function getMethods($include_private=true) { $methods = array(); if (!($this->_reflection instanceof ReflectionClass)) return array(); @@ -69,6 +139,14 @@ class smp_ClassMetaData extends smp_Pluggable { return array_keys($methods); } + /** + * getMethod + * + * Return an smp_MethodMetaData object for the given $method. + * + * @param $method string + * @return smp_MethodMetaData + */ final public function getMethod($method) { return new smp_MethodMetaData($this->_class,$method); } diff --git a/source/lib/simplicity/meta/meta_tag.php b/source/lib/simplicity/meta/meta_tag.php index 137e5fd..ef5264c 100644 --- a/source/lib/simplicity/meta/meta_tag.php +++ b/source/lib/simplicity/meta/meta_tag.php @@ -1,11 +1,38 @@ + * @copyright Copyright (c) 2009, John Le Drew + * @license http://www.opensource.org/licenses/mit-license.php MIT License + * @version 2.0.0-alpha + * + * @smp_core + */ abstract class smp_MetaTag { protected $_multiple = true; + /** + * parse + * + * Should parse the given tag $value and return the parsed result. + * + * @param $value string + * @return mixed + */ abstract public function parse($value); + /** + * hasMultipleValues + * + * Returns true or false if a tag can be listed multiple times. The value of this should be set by overriding + * the protected member $_multiple. + * + * @return boolean + */ final public function hasMultipleValues() { return $this->_multiple; } diff --git a/source/lib/simplicity/meta/method_meta.php b/source/lib/simplicity/meta/method_meta.php index b59b296..2114caf 100644 --- a/source/lib/simplicity/meta/method_meta.php +++ b/source/lib/simplicity/meta/method_meta.php @@ -1,16 +1,33 @@ + * @copyright Copyright (c) 2009, John Le Drew + * @license http://www.opensource.org/licenses/mit-license.php MIT License + * @version 2.0.0-alpha + * + * @smp_core + */ class smp_MethodMetaData extends smp_ClassMetaData { private $_method; + /** + * @inherited + */ protected function init($args) { $this->_class = $args[0]; $this->_method = $args[1]; return true; } - + + /** + * @inherited + */ public function getReflector() { return new ReflectionMethod($this->_class,$this->_method); } diff --git a/source/lib/simplicity/meta/tags/license.php b/source/lib/simplicity/meta/tags/license.php index 39f9188..580f40e 100644 --- a/source/lib/simplicity/meta/tags/license.php +++ b/source/lib/simplicity/meta/tags/license.php @@ -1,3 +1,14 @@ + * @copyright Copyright (c) 2009, John Le Drew + * @license http://www.opensource.org/licenses/mit-license.php MIT License + * @version 2.0.0-alpha + * + * @smp_core + */ class smp_LicenseMetaTag extends smp_LinkMetaTag {} \ No newline at end of file diff --git a/source/lib/simplicity/meta/tags/link.php b/source/lib/simplicity/meta/tags/link.php index 3656735..c50846a 100644 --- a/source/lib/simplicity/meta/tags/link.php +++ b/source/lib/simplicity/meta/tags/link.php @@ -1,10 +1,24 @@ + * @copyright Copyright (c) 2009, John Le Drew + * @license http://www.opensource.org/licenses/mit-license.php MIT License + * @version 2.0.0-alpha + * + * @smp_core + */ class smp_LinkMetaTag extends smp_MetaTag { protected $_multiple = false; + /** + * @inherited + */ public function parse($value) { $spl = explode(' ',$value); diff --git a/source/lib/simplicity/meta/tags/smp_children.php b/source/lib/simplicity/meta/tags/smp_children.php index efb97ad..6763888 100644 --- a/source/lib/simplicity/meta/tags/smp_children.php +++ b/source/lib/simplicity/meta/tags/smp_children.php @@ -1,8 +1,21 @@ + * @copyright Copyright (c) 2009, John Le Drew + * @license http://www.opensource.org/licenses/mit-license.php MIT License + * @version 2.0.0-alpha + * + * @smp_core + */ class smp_SmpChildrenMetaTag extends smp_MetaTag { - + /** + * @inherited + */ public function parse($value) { $spl = explode(' ',$value); diff --git a/source/lib/simplicity/meta/tags/smp_depends.php b/source/lib/simplicity/meta/tags/smp_depends.php index 6845e80..8c24286 100644 --- a/source/lib/simplicity/meta/tags/smp_depends.php +++ b/source/lib/simplicity/meta/tags/smp_depends.php @@ -1,8 +1,21 @@ + * @copyright Copyright (c) 2009, John Le Drew + * @license http://www.opensource.org/licenses/mit-license.php MIT License + * @version 2.0.0-alpha + * + * @smp_core + */ class smp_SmpDependsMetaTag extends smp_MetaTag { - + /** + * @inherited + */ public function parse($value) { $spl = explode(' ',$value); diff --git a/source/lib/simplicity/module/module.php b/source/lib/simplicity/module/module.php index c686a21..d4cccb9 100644 --- a/source/lib/simplicity/module/module.php +++ b/source/lib/simplicity/module/module.php @@ -9,7 +9,7 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core */ abstract class smp_Module extends smp_Pluggable { diff --git a/source/lib/simplicity/module/static.php b/source/lib/simplicity/module/static.php index 19afb89..2cbf5f2 100644 --- a/source/lib/simplicity/module/static.php +++ b/source/lib/simplicity/module/static.php @@ -10,6 +10,6 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha - * + * @smp_core */ interface smp_ModuleStatic {} \ No newline at end of file diff --git a/source/lib/simplicity/pluggable/pluggable.php b/source/lib/simplicity/pluggable/pluggable.php index 07e7fe9..862d40b 100644 --- a/source/lib/simplicity/pluggable/pluggable.php +++ b/source/lib/simplicity/pluggable/pluggable.php @@ -21,6 +21,7 @@ * @version 2.0.0-alpha * * @see smp_Tapped + * @smp_core */ abstract class smp_Pluggable { diff --git a/source/lib/simplicity/request/request.php b/source/lib/simplicity/request/request.php index e792174..72c3042 100644 --- a/source/lib/simplicity/request/request.php +++ b/source/lib/simplicity/request/request.php @@ -8,6 +8,8 @@ * @copyright Copyright (c) 2009, John Le Drew * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version 2.0.0-alpha + * + * @smp_core */ class smp_Request { @@ -28,6 +30,8 @@ class smp_Request static private $_instance; /** + * getInstance + * * Get a singleton instance of the class. * * @return smp_Request @@ -41,6 +45,8 @@ class smp_Request } /** + * init + * * Initialise the request. * */ @@ -50,6 +56,8 @@ class smp_Request } /** + * Constructor + * * Instanciate a new smp_Request * */ @@ -58,6 +66,8 @@ class smp_Request } /** + * getMethod + * * Get the HTTP method * * @return string @@ -69,6 +79,8 @@ class smp_Request } /** + * setMethod + * * Set the HTTP method * * @param $method string @@ -80,6 +92,8 @@ class smp_Request } /** + * getData + * * Get the parsed request data as an associative array * * @return array @@ -91,6 +105,8 @@ class smp_Request } /** + * setData + * * Set the parsed request data to an associative array * * @param array $data @@ -101,6 +117,8 @@ class smp_Request } /** + * getRawData + * * Get the raw unparsed data. * * @return string @@ -112,6 +130,8 @@ class smp_Request } /** + * setRawData + * * Set the raw unparsed data. * * @param $data string @@ -122,6 +142,8 @@ class smp_Request } /** + * getUri + * * Get the URI as a string. * * @return string @@ -133,6 +155,8 @@ class smp_Request } /** + * setUri + * * Set the URI to a string. * * @param $uri string @@ -143,7 +167,10 @@ class smp_Request } /** + * getUriSegments + * * Get the URI divided up into segments as an array. + * * @return array */ public function getUriSegments() @@ -153,6 +180,8 @@ class smp_Request } /** + * getUriSegment + * * Return the URI segment specified by the index. First segment is 0. * * @param $index int @@ -165,6 +194,8 @@ class smp_Request } /** + * getParams + * * Return the URI params as an array. * * @return array @@ -175,6 +206,8 @@ class smp_Request } /** + * getParam + * * Return the URI param specified by the index. First param is 0. * * @param $index int @@ -186,6 +219,8 @@ class smp_Request } /** + * getParsedParams + * * Return the parsed URI params as an associative array. * * @see parseUriParams @@ -198,6 +233,8 @@ class smp_Request } /** + * getParsedParam + * * Return the parsed URI param specified by the given key. * * @see parseUriParams @@ -211,6 +248,8 @@ class smp_Request } /** + * getHeader + * * Return the value of a header in the request. * * @param $header string @@ -223,6 +262,8 @@ class smp_Request } /** + * getHeaders + * * Return the request headers as an associative array. * * @return array @@ -234,6 +275,8 @@ class smp_Request } /** + * setHeader + * * Set the $header in the request to $value. * * @param $header string @@ -245,6 +288,8 @@ class smp_Request } /** + * delHeader + * * Delete the $header from the request. * * @param $header string @@ -255,6 +300,8 @@ class smp_Request } /** + * setHeaders + * * Set the request headers to the given array. * * @param $headers array @@ -410,13 +457,23 @@ class smp_Request } } + /** + * addSegmentIdentifier + * + * Add a segment identifier for use by 'parse' later. + * + * @see parse + * @param $name string + */ public function addSegmentIdentifier($name) { $this->_segment_identifiers[] = $name; } /** - * Parse the uri dividing it up into the provided $segments. If you provide the array('controller','action'), + * parse + * + * Parse the uri dividing it up into the previously defined segment identifiers. If you added the segments 'controller' ans 'action', * with the uri /foo/bar/param1/param2 you will get back an associative array array('controller'=>'foo','action'=>'bar','uri'=>array('param1','param2')). * * @param $segments array diff --git a/source/lib/simplicity/response/response.php b/source/lib/simplicity/response/response.php index bdc75f5..8ab2876 100644 --- a/source/lib/simplicity/response/response.php +++ b/source/lib/simplicity/response/response.php @@ -1,49 +1,61 @@ + * @copyright Copyright (c) 2009, John Le Drew + * @license http://www.opensource.org/licenses/mit-license.php MIT License + * @version 2.0.0-alpha + * + * @smp_core + */ class smp_Response { static private $_instance; private $_status_codes = array( - 100 => 'Continue', - 101 => 'Switching Protocols', - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - 400 => 'Bad Request', - 401 => 'Unathorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported' + 100 => 'Continue', + 101 => 'Switching Protocols', + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 307 => 'Temporary Redirect', + 400 => 'Bad Request', + 401 => 'Unathorized', + 402 => 'Payment Required', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Timeout', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Long', + 415 => 'Unsupported Media Type', + 416 => 'Requested Range Not Satisfiable', + 417 => 'Expectation Failed', + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Timeout', + 505 => 'HTTP Version Not Supported' ); private $_status = 200; @@ -51,6 +63,8 @@ class smp_Response { private $_body = ""; /** + * getInstance + * * Get a singleton instance of the class * * @return smp_Response @@ -68,6 +82,8 @@ class smp_Response { private function __clone() {} /** + * setContent + * * Set the body contents of the response. Will overwrite any existing content. * * @param $content string @@ -78,6 +94,8 @@ class smp_Response { } /** + * addContent + * * Append the given $content to the output. * * @param string $content @@ -88,7 +106,10 @@ class smp_Response { } /** + * getContent + * * Return the current body contents of the response. + * * @return string */ public function getContent() @@ -97,6 +118,8 @@ class smp_Response { } /** + * clearContent + * * Clear the current body contents. * */ @@ -106,6 +129,8 @@ class smp_Response { } /** + * setHeader + * * Set a header in the output providing the $header name and $value. * * @param $header string @@ -118,6 +143,8 @@ class smp_Response { } /** + * delHeader + * * Delete the specified $header from the response. * * @param $header string @@ -129,6 +156,8 @@ class smp_Response { } /** + * getHeader + * * Get the value of a $header in the response. * * @param $header string @@ -141,6 +170,8 @@ class smp_Response { } /** + * getHeaders + * * Return all the headers in the response as an associative array. * * @return array @@ -151,6 +182,8 @@ class smp_Response { } /** + * setStatus + * * Set the HTTP status code of the reponse. * * @param $status int @@ -162,6 +195,8 @@ class smp_Response { } /** + * sendStatus + * * Send the status to the browser. * */ @@ -172,6 +207,8 @@ class smp_Response { } /** + * sendHeaders + * * Send all headers to the browser. * */ @@ -184,6 +221,8 @@ class smp_Response { } /** + * sendContent + * * Send the body content to the browser. * */ -- 2.11.4.GIT