@@ -9,19 +9,19 @@ |
||
| 9 | 9 | |
| 10 | 10 | class Server implements RequestInterface |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * get parameter |
|
| 14 | - * @param string $name |
|
| 15 | - * @param string $default |
|
| 16 | - * @return string |
|
| 17 | - */ |
|
| 18 | - public function get(string $name, string $default = null) : string |
|
| 19 | - { |
|
| 20 | - if (isset($_SERVER[$name]) && $_SERVER[$name] != '') { |
|
| 21 | - return $_SERVER[$name]; |
|
| 22 | - } |
|
| 23 | - else if ($default !== null) { |
|
| 24 | - return $default; |
|
| 25 | - } |
|
| 26 | - } |
|
| 12 | + /** |
|
| 13 | + * get parameter |
|
| 14 | + * @param string $name |
|
| 15 | + * @param string $default |
|
| 16 | + * @return string |
|
| 17 | + */ |
|
| 18 | + public function get(string $name, string $default = null) : string |
|
| 19 | + { |
|
| 20 | + if (isset($_SERVER[$name]) && $_SERVER[$name] != '') { |
|
| 21 | + return $_SERVER[$name]; |
|
| 22 | + } |
|
| 23 | + else if ($default !== null) { |
|
| 24 | + return $default; |
|
| 25 | + } |
|
| 26 | + } |
|
| 27 | 27 | } |
@@ -19,8 +19,7 @@ |
||
| 19 | 19 | { |
| 20 | 20 | if (isset($_SERVER[$name]) && $_SERVER[$name] != '') { |
| 21 | 21 | return $_SERVER[$name]; |
| 22 | - } |
|
| 23 | - else if ($default !== null) { |
|
| 22 | + } else if ($default !== null) { |
|
| 24 | 23 | return $default; |
| 25 | 24 | } |
| 26 | 25 | } |
@@ -9,19 +9,19 @@ |
||
| 9 | 9 | |
| 10 | 10 | class Request implements RequestInterface |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * get parameter |
|
| 14 | - * @param string $name |
|
| 15 | - * @param string $default |
|
| 16 | - * @return string |
|
| 17 | - */ |
|
| 18 | - public function get(string $name, string $default = null) : string |
|
| 19 | - { |
|
| 20 | - if (isset($_POST[$name]) && $_POST[$name] != '') { |
|
| 21 | - return $_POST[$name]; |
|
| 22 | - } |
|
| 23 | - else if ($default !== null) { |
|
| 24 | - return $default; |
|
| 25 | - } |
|
| 26 | - } |
|
| 12 | + /** |
|
| 13 | + * get parameter |
|
| 14 | + * @param string $name |
|
| 15 | + * @param string $default |
|
| 16 | + * @return string |
|
| 17 | + */ |
|
| 18 | + public function get(string $name, string $default = null) : string |
|
| 19 | + { |
|
| 20 | + if (isset($_POST[$name]) && $_POST[$name] != '') { |
|
| 21 | + return $_POST[$name]; |
|
| 22 | + } |
|
| 23 | + else if ($default !== null) { |
|
| 24 | + return $default; |
|
| 25 | + } |
|
| 26 | + } |
|
| 27 | 27 | } |
@@ -19,8 +19,7 @@ |
||
| 19 | 19 | { |
| 20 | 20 | if (isset($_POST[$name]) && $_POST[$name] != '') { |
| 21 | 21 | return $_POST[$name]; |
| 22 | - } |
|
| 23 | - else if ($default !== null) { |
|
| 22 | + } else if ($default !== null) { |
|
| 24 | 23 | return $default; |
| 25 | 24 | } |
| 26 | 25 | } |
@@ -9,19 +9,19 @@ |
||
| 9 | 9 | |
| 10 | 10 | class Query implements RequestInterface |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * get parameter |
|
| 14 | - * @param string $name |
|
| 15 | - * @param string $default |
|
| 16 | - * @return string |
|
| 17 | - */ |
|
| 18 | - public function get(string $name, string $default = null) : string |
|
| 19 | - { |
|
| 20 | - if (isset($_GET[$name]) && $_GET[$name] != '') { |
|
| 21 | - return $_GET[$name]; |
|
| 22 | - } |
|
| 23 | - else if ($default !== null) { |
|
| 24 | - return $default; |
|
| 25 | - } |
|
| 26 | - } |
|
| 12 | + /** |
|
| 13 | + * get parameter |
|
| 14 | + * @param string $name |
|
| 15 | + * @param string $default |
|
| 16 | + * @return string |
|
| 17 | + */ |
|
| 18 | + public function get(string $name, string $default = null) : string |
|
| 19 | + { |
|
| 20 | + if (isset($_GET[$name]) && $_GET[$name] != '') { |
|
| 21 | + return $_GET[$name]; |
|
| 22 | + } |
|
| 23 | + else if ($default !== null) { |
|
| 24 | + return $default; |
|
| 25 | + } |
|
| 26 | + } |
|
| 27 | 27 | } |
@@ -19,8 +19,7 @@ |
||
| 19 | 19 | { |
| 20 | 20 | if (isset($_GET[$name]) && $_GET[$name] != '') { |
| 21 | 21 | return $_GET[$name]; |
| 22 | - } |
|
| 23 | - else if ($default !== null) { |
|
| 22 | + } else if ($default !== null) { |
|
| 24 | 23 | return $default; |
| 25 | 24 | } |
| 26 | 25 | } |
@@ -9,19 +9,19 @@ |
||
| 9 | 9 | |
| 10 | 10 | class Cookies implements RequestInterface |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * get parameter |
|
| 14 | - * @param string $name |
|
| 15 | - * @param string $default |
|
| 16 | - * @return string |
|
| 17 | - */ |
|
| 18 | - public function get(string $name, string $default = null) : string |
|
| 19 | - { |
|
| 20 | - if (isset($_COOKIE[$name]) && $_COOKIE[$name] != '') { |
|
| 21 | - return $_COOKIE[$name]; |
|
| 22 | - } |
|
| 23 | - else if ($default !== null) { |
|
| 24 | - return $default; |
|
| 25 | - } |
|
| 26 | - } |
|
| 12 | + /** |
|
| 13 | + * get parameter |
|
| 14 | + * @param string $name |
|
| 15 | + * @param string $default |
|
| 16 | + * @return string |
|
| 17 | + */ |
|
| 18 | + public function get(string $name, string $default = null) : string |
|
| 19 | + { |
|
| 20 | + if (isset($_COOKIE[$name]) && $_COOKIE[$name] != '') { |
|
| 21 | + return $_COOKIE[$name]; |
|
| 22 | + } |
|
| 23 | + else if ($default !== null) { |
|
| 24 | + return $default; |
|
| 25 | + } |
|
| 26 | + } |
|
| 27 | 27 | } |
@@ -19,8 +19,7 @@ |
||
| 19 | 19 | { |
| 20 | 20 | if (isset($_COOKIE[$name]) && $_COOKIE[$name] != '') { |
| 21 | 21 | return $_COOKIE[$name]; |
| 22 | - } |
|
| 23 | - else if ($default !== null) { |
|
| 22 | + } else if ($default !== null) { |
|
| 24 | 23 | return $default; |
| 25 | 24 | } |
| 26 | 25 | } |
@@ -9,37 +9,37 @@ |
||
| 9 | 9 | |
| 10 | 10 | class Headers implements RequestInterface |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * get parameter |
|
| 14 | - * @param string $name |
|
| 15 | - * @param string $default |
|
| 16 | - * @return string |
|
| 17 | - */ |
|
| 18 | - public function get(string $name, string $default = null) : string |
|
| 19 | - { |
|
| 20 | - if (isset(apache_request_headers()[$name]) && apache_request_headers()[$name] != '') { |
|
| 21 | - return apache_request_headers()[$name]; |
|
| 22 | - } |
|
| 23 | - else if ($default !== null) { |
|
| 24 | - return $default; |
|
| 25 | - } |
|
| 26 | - } |
|
| 12 | + /** |
|
| 13 | + * get parameter |
|
| 14 | + * @param string $name |
|
| 15 | + * @param string $default |
|
| 16 | + * @return string |
|
| 17 | + */ |
|
| 18 | + public function get(string $name, string $default = null) : string |
|
| 19 | + { |
|
| 20 | + if (isset(apache_request_headers()[$name]) && apache_request_headers()[$name] != '') { |
|
| 21 | + return apache_request_headers()[$name]; |
|
| 22 | + } |
|
| 23 | + else if ($default !== null) { |
|
| 24 | + return $default; |
|
| 25 | + } |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * set a new header |
|
| 30 | - * @param string $name |
|
| 31 | - * @param string $value |
|
| 32 | - * @return string|Headers |
|
| 33 | - */ |
|
| 34 | - public function set(string $name, string $value = null) : Headers |
|
| 35 | - { |
|
| 36 | - if ($value !== null) { |
|
| 37 | - header($name . ': ' . $value); |
|
| 38 | - } |
|
| 39 | - else { |
|
| 40 | - header($name); |
|
| 41 | - } |
|
| 28 | + /** |
|
| 29 | + * set a new header |
|
| 30 | + * @param string $name |
|
| 31 | + * @param string $value |
|
| 32 | + * @return string|Headers |
|
| 33 | + */ |
|
| 34 | + public function set(string $name, string $value = null) : Headers |
|
| 35 | + { |
|
| 36 | + if ($value !== null) { |
|
| 37 | + header($name . ': ' . $value); |
|
| 38 | + } |
|
| 39 | + else { |
|
| 40 | + header($name); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - return $this; |
|
| 44 | - } |
|
| 43 | + return $this; |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -19,8 +19,7 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | if (isset(apache_request_headers()[$name]) && apache_request_headers()[$name] != '') { |
| 21 | 21 | return apache_request_headers()[$name]; |
| 22 | - } |
|
| 23 | - else if ($default !== null) { |
|
| 22 | + } else if ($default !== null) { |
|
| 24 | 23 | return $default; |
| 25 | 24 | } |
| 26 | 25 | } |
@@ -35,8 +34,7 @@ discard block |
||
| 35 | 34 | { |
| 36 | 35 | if ($value !== null) { |
| 37 | 36 | header($name . ': ' . $value); |
| 38 | - } |
|
| 39 | - else { |
|
| 37 | + } else { |
|
| 40 | 38 | header($name); |
| 41 | 39 | } |
| 42 | 40 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | error_reporting($iLevel); |
| 153 | 153 | |
| 154 | - set_error_handler(function ($iErrNo, $sErrStr, $sErrFile, $iErrLine) |
|
| 154 | + set_error_handler(function($iErrNo, $sErrStr, $sErrFile, $iErrLine) |
|
| 155 | 155 | { |
| 156 | 156 | $aContext = array('file' => $sErrFile, 'line' => $iErrLine); |
| 157 | 157 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | self::_initLogFile(); |
| 217 | 217 | self::$_bActivateException = true; |
| 218 | 218 | |
| 219 | - set_exception_handler(function (\Exception $oException) |
|
| 219 | + set_exception_handler(function(\Exception $oException) |
|
| 220 | 220 | { |
| 221 | 221 | $aContext = array('file' => $oException->getFile(), 'line' => $oException->getLine()); |
| 222 | 222 | self::getInstance()->critical($oException->getMessage(), $aContext); |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | else { |
| 413 | 413 | |
| 414 | 414 | if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) { |
| 415 | - error_log(Bash::setColor('############### ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . ' ###############', 'cyan')); |
|
| 415 | + error_log(Bash::setColor('############### '.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].' ###############', 'cyan')); |
|
| 416 | 416 | } |
| 417 | 417 | } |
| 418 | 418 | } |
@@ -148,6 +148,6 @@ |
||
| 148 | 148 | */ |
| 149 | 149 | private static function _applyCode(string $sContent, string $sCode) : string |
| 150 | 150 | { |
| 151 | - return "\033[" . $sCode . "m" . $sContent . "\033[0m\n"; |
|
| 151 | + return "\033[".$sCode."m".$sContent."\033[0m\n"; |
|
| 152 | 152 | } |
| 153 | 153 | } |
@@ -7,12 +7,12 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class LogLevel |
| 9 | 9 | { |
| 10 | - const EMERGENCY = 'emergency'; |
|
| 11 | - const ALERT = 'alert'; |
|
| 12 | - const CRITICAL = 'critical'; |
|
| 13 | - const ERROR = 'error'; |
|
| 14 | - const WARNING = 'warning'; |
|
| 15 | - const NOTICE = 'notice'; |
|
| 16 | - const INFO = 'info'; |
|
| 17 | - const DEBUG = 'debug'; |
|
| 10 | + const EMERGENCY = 'emergency'; |
|
| 11 | + const ALERT = 'alert'; |
|
| 12 | + const CRITICAL = 'critical'; |
|
| 13 | + const ERROR = 'error'; |
|
| 14 | + const WARNING = 'warning'; |
|
| 15 | + const NOTICE = 'notice'; |
|
| 16 | + const INFO = 'info'; |
|
| 17 | + const DEBUG = 'debug'; |
|
| 18 | 18 | } |
@@ -19,96 +19,96 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | interface LoggerInterface |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * System is unusable. |
|
| 24 | - * |
|
| 25 | - * @param string $message |
|
| 26 | - * @param array $context |
|
| 27 | - * @return null |
|
| 28 | - */ |
|
| 29 | - public function emergency($message, array $context = array()); |
|
| 22 | + /** |
|
| 23 | + * System is unusable. |
|
| 24 | + * |
|
| 25 | + * @param string $message |
|
| 26 | + * @param array $context |
|
| 27 | + * @return null |
|
| 28 | + */ |
|
| 29 | + public function emergency($message, array $context = array()); |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Action must be taken immediately. |
|
| 33 | - * |
|
| 34 | - * Example: Entire website down, database unavailable, etc. This should |
|
| 35 | - * trigger the SMS alerts and wake you up. |
|
| 36 | - * |
|
| 37 | - * @param string $message |
|
| 38 | - * @param array $context |
|
| 39 | - * @return null |
|
| 40 | - */ |
|
| 41 | - public function alert($message, array $context = array()); |
|
| 31 | + /** |
|
| 32 | + * Action must be taken immediately. |
|
| 33 | + * |
|
| 34 | + * Example: Entire website down, database unavailable, etc. This should |
|
| 35 | + * trigger the SMS alerts and wake you up. |
|
| 36 | + * |
|
| 37 | + * @param string $message |
|
| 38 | + * @param array $context |
|
| 39 | + * @return null |
|
| 40 | + */ |
|
| 41 | + public function alert($message, array $context = array()); |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Critical conditions. |
|
| 45 | - * |
|
| 46 | - * Example: Application component unavailable, unexpected exception. |
|
| 47 | - * |
|
| 48 | - * @param string $message |
|
| 49 | - * @param array $context |
|
| 50 | - * @return null |
|
| 51 | - */ |
|
| 52 | - public function critical($message, array $context = array()); |
|
| 43 | + /** |
|
| 44 | + * Critical conditions. |
|
| 45 | + * |
|
| 46 | + * Example: Application component unavailable, unexpected exception. |
|
| 47 | + * |
|
| 48 | + * @param string $message |
|
| 49 | + * @param array $context |
|
| 50 | + * @return null |
|
| 51 | + */ |
|
| 52 | + public function critical($message, array $context = array()); |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Runtime errors that do not require immediate action but should typically |
|
| 56 | - * be logged and monitored. |
|
| 57 | - * |
|
| 58 | - * @param string $message |
|
| 59 | - * @param array $context |
|
| 60 | - * @return null |
|
| 61 | - */ |
|
| 62 | - public function error($message, array $context = array()); |
|
| 54 | + /** |
|
| 55 | + * Runtime errors that do not require immediate action but should typically |
|
| 56 | + * be logged and monitored. |
|
| 57 | + * |
|
| 58 | + * @param string $message |
|
| 59 | + * @param array $context |
|
| 60 | + * @return null |
|
| 61 | + */ |
|
| 62 | + public function error($message, array $context = array()); |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Exceptional occurrences that are not errors. |
|
| 66 | - * |
|
| 67 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
| 68 | - * that are not necessarily wrong. |
|
| 69 | - * |
|
| 70 | - * @param string $message |
|
| 71 | - * @param array $context |
|
| 72 | - * @return null |
|
| 73 | - */ |
|
| 74 | - public function warning($message, array $context = array()); |
|
| 64 | + /** |
|
| 65 | + * Exceptional occurrences that are not errors. |
|
| 66 | + * |
|
| 67 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
| 68 | + * that are not necessarily wrong. |
|
| 69 | + * |
|
| 70 | + * @param string $message |
|
| 71 | + * @param array $context |
|
| 72 | + * @return null |
|
| 73 | + */ |
|
| 74 | + public function warning($message, array $context = array()); |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Normal but significant events. |
|
| 78 | - * |
|
| 79 | - * @param string $message |
|
| 80 | - * @param array $context |
|
| 81 | - * @return null |
|
| 82 | - */ |
|
| 83 | - public function notice($message, array $context = array()); |
|
| 76 | + /** |
|
| 77 | + * Normal but significant events. |
|
| 78 | + * |
|
| 79 | + * @param string $message |
|
| 80 | + * @param array $context |
|
| 81 | + * @return null |
|
| 82 | + */ |
|
| 83 | + public function notice($message, array $context = array()); |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Interesting events. |
|
| 87 | - * |
|
| 88 | - * Example: User logs in, SQL logs. |
|
| 89 | - * |
|
| 90 | - * @param string $message |
|
| 91 | - * @param array $context |
|
| 92 | - * @return null |
|
| 93 | - */ |
|
| 94 | - public function info($message, array $context = array()); |
|
| 85 | + /** |
|
| 86 | + * Interesting events. |
|
| 87 | + * |
|
| 88 | + * Example: User logs in, SQL logs. |
|
| 89 | + * |
|
| 90 | + * @param string $message |
|
| 91 | + * @param array $context |
|
| 92 | + * @return null |
|
| 93 | + */ |
|
| 94 | + public function info($message, array $context = array()); |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Detailed debug information. |
|
| 98 | - * |
|
| 99 | - * @param string $message |
|
| 100 | - * @param array $context |
|
| 101 | - * @return null |
|
| 102 | - */ |
|
| 103 | - public function debug($message, array $context = array()); |
|
| 96 | + /** |
|
| 97 | + * Detailed debug information. |
|
| 98 | + * |
|
| 99 | + * @param string $message |
|
| 100 | + * @param array $context |
|
| 101 | + * @return null |
|
| 102 | + */ |
|
| 103 | + public function debug($message, array $context = array()); |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Logs with an arbitrary level. |
|
| 107 | - * |
|
| 108 | - * @param mixed $level |
|
| 109 | - * @param string $message |
|
| 110 | - * @param array $context |
|
| 111 | - * @return null |
|
| 112 | - */ |
|
| 113 | - public function log($level, $message, array $context = array()); |
|
| 105 | + /** |
|
| 106 | + * Logs with an arbitrary level. |
|
| 107 | + * |
|
| 108 | + * @param mixed $level |
|
| 109 | + * @param string $message |
|
| 110 | + * @param array $context |
|
| 111 | + * @return null |
|
| 112 | + */ |
|
| 113 | + public function log($level, $message, array $context = array()); |
|
| 114 | 114 | } |