@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -32,37 +32,37 @@ |
||
32 | 32 | */ |
33 | 33 | class Demo extends Controller |
34 | 34 | { |
35 | - /** |
|
36 | - * Constructor |
|
37 | - * |
|
38 | - * @access public |
|
39 | - * @return Demo |
|
40 | - */ |
|
41 | - public function __construct() |
|
42 | - { |
|
43 | - parent::__construct(); |
|
44 | - } |
|
35 | + /** |
|
36 | + * Constructor |
|
37 | + * |
|
38 | + * @access public |
|
39 | + * @return Demo |
|
40 | + */ |
|
41 | + public function __construct() |
|
42 | + { |
|
43 | + parent::__construct(); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * bootstrap |
|
48 | - * |
|
49 | - * @access public |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - public function bootstrap() |
|
53 | - { |
|
54 | - ; |
|
55 | - } |
|
46 | + /** |
|
47 | + * bootstrap |
|
48 | + * |
|
49 | + * @access public |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + public function bootstrap() |
|
53 | + { |
|
54 | + ; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * install method |
|
59 | - * |
|
60 | - * @access public |
|
61 | - * @param string $sPortal |
|
62 | - * @return void |
|
63 | - */ |
|
64 | - public function install($sPortal) |
|
65 | - { |
|
66 | - $this->installDb; |
|
67 | - } |
|
57 | + /** |
|
58 | + * install method |
|
59 | + * |
|
60 | + * @access public |
|
61 | + * @param string $sPortal |
|
62 | + * @return void |
|
63 | + */ |
|
64 | + public function install($sPortal) |
|
65 | + { |
|
66 | + $this->installDb; |
|
67 | + } |
|
68 | 68 | } |
@@ -6,42 +6,42 @@ |
||
6 | 6 | |
7 | 7 | class Phpunit extends Controller |
8 | 8 | { |
9 | - /** |
|
10 | - * Constructs a test case with the given name. |
|
11 | - * |
|
12 | - */ |
|
13 | - public function __construct() |
|
14 | - { |
|
15 | - parent::__construct(); |
|
16 | - } |
|
17 | - |
|
18 | - /** |
|
19 | - * new method to launch a web server |
|
20 | - * @param array $options |
|
21 | - * @tutorial php bin/console server:run |
|
22 | - * php bin/console server:run -a 192.168.0.1:8000 |
|
23 | - */ |
|
24 | - public function phpunit(array $options = array()) |
|
25 | - { |
|
26 | - ob_get_clean(); |
|
27 | - |
|
28 | - $files = scandir(__DIR__.'/../../../../tests'); |
|
29 | - |
|
30 | - foreach ($files as $one) { |
|
31 | - |
|
32 | - if (is_dir(__DIR__.'/../../../../tests/'.$one) && $one != '..' && $one != '.') { |
|
33 | - |
|
34 | - $controllerFiles = scandir(__DIR__.'/../../../../tests'.'/'.$one.'/app/Controller'); |
|
35 | - |
|
36 | - foreach ($controllerFiles as $oneController) { |
|
37 | - |
|
38 | - if (is_file(__DIR__.'/../../../../tests/'.$one.'/app/Controller/' . $oneController) && $oneController != '..' && $oneController != '.') { |
|
39 | - |
|
40 | - $unitTest = new \PHPUnit_TextUI_Command; |
|
41 | - $unitTest->run([__DIR__.'/../../../../tests/'.$one.'/app/Controller/' . $oneController]); |
|
42 | - } |
|
43 | - } |
|
44 | - } |
|
45 | - } |
|
46 | - } |
|
9 | + /** |
|
10 | + * Constructs a test case with the given name. |
|
11 | + * |
|
12 | + */ |
|
13 | + public function __construct() |
|
14 | + { |
|
15 | + parent::__construct(); |
|
16 | + } |
|
17 | + |
|
18 | + /** |
|
19 | + * new method to launch a web server |
|
20 | + * @param array $options |
|
21 | + * @tutorial php bin/console server:run |
|
22 | + * php bin/console server:run -a 192.168.0.1:8000 |
|
23 | + */ |
|
24 | + public function phpunit(array $options = array()) |
|
25 | + { |
|
26 | + ob_get_clean(); |
|
27 | + |
|
28 | + $files = scandir(__DIR__.'/../../../../tests'); |
|
29 | + |
|
30 | + foreach ($files as $one) { |
|
31 | + |
|
32 | + if (is_dir(__DIR__.'/../../../../tests/'.$one) && $one != '..' && $one != '.') { |
|
33 | + |
|
34 | + $controllerFiles = scandir(__DIR__.'/../../../../tests'.'/'.$one.'/app/Controller'); |
|
35 | + |
|
36 | + foreach ($controllerFiles as $oneController) { |
|
37 | + |
|
38 | + if (is_file(__DIR__.'/../../../../tests/'.$one.'/app/Controller/' . $oneController) && $oneController != '..' && $oneController != '.') { |
|
39 | + |
|
40 | + $unitTest = new \PHPUnit_TextUI_Command; |
|
41 | + $unitTest->run([__DIR__.'/../../../../tests/'.$one.'/app/Controller/' . $oneController]); |
|
42 | + } |
|
43 | + } |
|
44 | + } |
|
45 | + } |
|
46 | + } |
|
47 | 47 | } |
@@ -7,68 +7,68 @@ |
||
7 | 7 | |
8 | 8 | class Server extends Controller |
9 | 9 | { |
10 | - /** |
|
11 | - * new method to launch a web server |
|
12 | - * @param array $options |
|
13 | - * @tutorial php bin/console server:run |
|
14 | - * php bin/console server:run -a 192.168.0.1:8000 |
|
15 | - */ |
|
16 | - public function run(array $options = array()) |
|
17 | - { |
|
18 | - ob_get_clean(); |
|
10 | + /** |
|
11 | + * new method to launch a web server |
|
12 | + * @param array $options |
|
13 | + * @tutorial php bin/console server:run |
|
14 | + * php bin/console server:run -a 192.168.0.1:8000 |
|
15 | + */ |
|
16 | + public function run(array $options = array()) |
|
17 | + { |
|
18 | + ob_get_clean(); |
|
19 | 19 | |
20 | - if (!isset($options['a'])) { |
|
21 | - $options['a'] = 'localhost:8000'; |
|
22 | - } |
|
20 | + if (!isset($options['a'])) { |
|
21 | + $options['a'] = 'localhost:8000'; |
|
22 | + } |
|
23 | 23 | |
24 | - echo "\n\n"; |
|
25 | - echo Bash::setBackground(" ", 'green'); |
|
26 | - echo Bash::setBackground(" [OK] Start web server ", 'green'); |
|
27 | - echo Bash::setBackground(" ", 'green'); |
|
28 | - echo "\n\n"; |
|
29 | - echo " > Use ".$options['a']." in browser"; |
|
30 | - echo "\n\n"; |
|
31 | - echo " > Clic Ctrl+C to stop the web server"; |
|
32 | - echo "\n\n"; |
|
24 | + echo "\n\n"; |
|
25 | + echo Bash::setBackground(" ", 'green'); |
|
26 | + echo Bash::setBackground(" [OK] Start web server ", 'green'); |
|
27 | + echo Bash::setBackground(" ", 'green'); |
|
28 | + echo "\n\n"; |
|
29 | + echo " > Use ".$options['a']." in browser"; |
|
30 | + echo "\n\n"; |
|
31 | + echo " > Clic Ctrl+C to stop the web server"; |
|
32 | + echo "\n\n"; |
|
33 | 33 | |
34 | - exec('php -S '.$options['a'].' /public/index.php'); |
|
35 | - } |
|
34 | + exec('php -S '.$options['a'].' /public/index.php'); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * check if a server web is launched |
|
39 | - * @param array $options |
|
40 | - * @tutorial php bin/console server:status |
|
41 | - * php bin/console server:status -a 192.168.0.1:8000 |
|
42 | - */ |
|
43 | - public function status(array $options = array()) |
|
44 | - { |
|
45 | - ob_get_clean(); |
|
37 | + /** |
|
38 | + * check if a server web is launched |
|
39 | + * @param array $options |
|
40 | + * @tutorial php bin/console server:status |
|
41 | + * php bin/console server:status -a 192.168.0.1:8000 |
|
42 | + */ |
|
43 | + public function status(array $options = array()) |
|
44 | + { |
|
45 | + ob_get_clean(); |
|
46 | 46 | |
47 | - if (!isset($options['a'])) { |
|
48 | - $options['a'] = 'localhost:8000'; |
|
49 | - } |
|
47 | + if (!isset($options['a'])) { |
|
48 | + $options['a'] = 'localhost:8000'; |
|
49 | + } |
|
50 | 50 | |
51 | - list($hostname, $port) = explode(':', $options['a']); |
|
51 | + list($hostname, $port) = explode(':', $options['a']); |
|
52 | 52 | |
53 | - if (false !== $fp = @fsockopen($hostname, $port, $errno, $errstr, 1)) { |
|
54 | - fclose($fp); |
|
53 | + if (false !== $fp = @fsockopen($hostname, $port, $errno, $errstr, 1)) { |
|
54 | + fclose($fp); |
|
55 | 55 | |
56 | - echo "\n\n"; |
|
57 | - echo Bash::setBackground(" ", 'green'); |
|
58 | - echo Bash::setBackground(" [OK] A web server is launched ", 'green'); |
|
59 | - echo Bash::setBackground(" ", 'green'); |
|
60 | - echo "\n\n"; |
|
61 | - echo " > Check realized on ".$options['a']; |
|
62 | - echo "\n\n"; |
|
63 | - } |
|
64 | - else { |
|
65 | - echo "\n\n"; |
|
66 | - echo Bash::setBackground(" ", 'red'); |
|
67 | - echo Bash::setBackground(" [WARNING] A web server is not used ", 'red'); |
|
68 | - echo Bash::setBackground(" ", 'red'); |
|
69 | - echo "\n\n"; |
|
70 | - echo " > Check realized on ".$options['a']; |
|
71 | - echo "\n\n"; |
|
72 | - } |
|
73 | - } |
|
56 | + echo "\n\n"; |
|
57 | + echo Bash::setBackground(" ", 'green'); |
|
58 | + echo Bash::setBackground(" [OK] A web server is launched ", 'green'); |
|
59 | + echo Bash::setBackground(" ", 'green'); |
|
60 | + echo "\n\n"; |
|
61 | + echo " > Check realized on ".$options['a']; |
|
62 | + echo "\n\n"; |
|
63 | + } |
|
64 | + else { |
|
65 | + echo "\n\n"; |
|
66 | + echo Bash::setBackground(" ", 'red'); |
|
67 | + echo Bash::setBackground(" [WARNING] A web server is not used ", 'red'); |
|
68 | + echo Bash::setBackground(" ", 'red'); |
|
69 | + echo "\n\n"; |
|
70 | + echo " > Check realized on ".$options['a']; |
|
71 | + echo "\n\n"; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | } |