@@ -16,7 +16,7 @@ |
||
16 | 16 | */ |
17 | 17 | trait ExceptionLoggerTrait |
18 | 18 | { |
19 | - abstract protected function logImpl($level, $message, array $context = array()); |
|
19 | + abstract protected function logImpl($level, $message, array $context = array()); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * {@inheritDoc} |
@@ -16,6 +16,9 @@ |
||
16 | 16 | */ |
17 | 17 | trait ExceptionLoggerTrait |
18 | 18 | { |
19 | + /** |
|
20 | + * @param string $message |
|
21 | + */ |
|
19 | 22 | abstract protected function logImpl($level, $message, array $context = array()); |
20 | 23 | |
21 | 24 | /** |
@@ -472,6 +472,6 @@ |
||
472 | 472 | */ |
473 | 473 | public function isOpen() |
474 | 474 | { |
475 | - return true; |
|
475 | + return true; |
|
476 | 476 | } |
477 | 477 | } |
@@ -49,6 +49,6 @@ |
||
49 | 49 | */ |
50 | 50 | public function __construct($message, array $context = array(), $code = 0, Exception $previous = null) |
51 | 51 | { |
52 | - parent::__construct($message, $context, $code, $previous); |
|
52 | + parent::__construct($message, $context, $code, $previous); |
|
53 | 53 | } |
54 | 54 | } |
@@ -8,24 +8,24 @@ discard block |
||
8 | 8 | |
9 | 9 | abstract class BasicLogger extends AbstractLogger |
10 | 10 | { |
11 | - /** |
|
12 | - * The level threshold where to log |
|
13 | - * |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - private $level; |
|
11 | + /** |
|
12 | + * The level threshold where to log |
|
13 | + * |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + private $level; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Set the log level threshold |
|
20 | - * |
|
21 | - * @param string $level |
|
22 | - * @return BasicLogger |
|
23 | - */ |
|
24 | - public function setLevel(string $level):BasicLogger |
|
25 | - { |
|
26 | - $this->level = $level; |
|
27 | - return $this; |
|
28 | - } |
|
18 | + /** |
|
19 | + * Set the log level threshold |
|
20 | + * |
|
21 | + * @param string $level |
|
22 | + * @return BasicLogger |
|
23 | + */ |
|
24 | + public function setLevel(string $level):BasicLogger |
|
25 | + { |
|
26 | + $this->level = $level; |
|
27 | + return $this; |
|
28 | + } |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Checks the given level |
@@ -89,32 +89,32 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function log($level, $message, array $context = array()) |
91 | 91 | { |
92 | - if( $this->levelHasReached($level) ) { |
|
93 | - $this->logImpl($level, $message, $context); |
|
94 | - } |
|
92 | + if( $this->levelHasReached($level) ) { |
|
93 | + $this->logImpl($level, $message, $context); |
|
94 | + } |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | protected function levelHasReached($level):bool |
98 | 98 | { |
99 | - $result = true; |
|
99 | + $result = true; |
|
100 | 100 | |
101 | - $orderedLevels = array( |
|
102 | - LogLevel::EMERGENCY => 0, |
|
103 | - LogLevel::ALERT => 1, |
|
104 | - LogLevel::CRITICAL => 2, |
|
105 | - LogLevel::ERROR => 3, |
|
106 | - LogLevel::WARNING => 4, |
|
107 | - LogLevel::NOTICE => 5, |
|
108 | - LogLevel::INFO => 6, |
|
109 | - LogLevel::DEBUG => 7 |
|
110 | - ); |
|
101 | + $orderedLevels = array( |
|
102 | + LogLevel::EMERGENCY => 0, |
|
103 | + LogLevel::ALERT => 1, |
|
104 | + LogLevel::CRITICAL => 2, |
|
105 | + LogLevel::ERROR => 3, |
|
106 | + LogLevel::WARNING => 4, |
|
107 | + LogLevel::NOTICE => 5, |
|
108 | + LogLevel::INFO => 6, |
|
109 | + LogLevel::DEBUG => 7 |
|
110 | + ); |
|
111 | 111 | |
112 | - if ( $this->level ) { |
|
113 | - $threshold = $orderedLevels[$this->level]; |
|
114 | - $reached = $orderedLevels[$level]; |
|
115 | - $result = $reached <= $threshold; |
|
116 | - } |
|
112 | + if ( $this->level ) { |
|
113 | + $threshold = $orderedLevels[$this->level]; |
|
114 | + $reached = $orderedLevels[$level]; |
|
115 | + $result = $reached <= $threshold; |
|
116 | + } |
|
117 | 117 | |
118 | - return $result; |
|
118 | + return $result; |
|
119 | 119 | } |
120 | 120 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function log($level, $message, array $context = array()) |
91 | 91 | { |
92 | - if( $this->levelHasReached($level) ) { |
|
92 | + if ($this->levelHasReached($level)) { |
|
93 | 93 | $this->logImpl($level, $message, $context); |
94 | 94 | } |
95 | 95 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | LogLevel::DEBUG => 7 |
110 | 110 | ); |
111 | 111 | |
112 | - if ( $this->level ) { |
|
112 | + if ($this->level) { |
|
113 | 113 | $threshold = $orderedLevels[$this->level]; |
114 | 114 | $reached = $orderedLevels[$level]; |
115 | 115 | $result = $reached <= $threshold; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $code = socket_last_error(); |
157 | 157 | if ($code != 0) { |
158 | 158 | if ($code != 10053) { |
159 | - throw new SocketException(socket_strerror($code), array(), $code); |
|
159 | + throw new SocketException(socket_strerror($code), array(), $code); |
|
160 | 160 | } else { |
161 | 161 | $this->handle = null; |
162 | 162 | } |
@@ -210,6 +210,6 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function isOpen() |
212 | 212 | { |
213 | - return is_resource($this->handle); |
|
213 | + return is_resource($this->handle); |
|
214 | 214 | } |
215 | 215 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $this->endpoint = $endpoint; |
43 | 43 | $this->handle = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); |
44 | 44 | |
45 | - if (! is_resource($this->handle)) { |
|
45 | + if (!is_resource($this->handle)) { |
|
46 | 46 | $code = socket_last_error(); |
47 | 47 | throw new SocketException(socket_strerror($code), array(), $code); |
48 | 48 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function ready() |
76 | 76 | { |
77 | - if (! is_resource($this->handle)) { |
|
77 | + if (!is_resource($this->handle)) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | |
98 | - if (! in_array($this->handle, $read)) { |
|
98 | + if (!in_array($this->handle, $read)) { |
|
99 | 99 | return false; |
100 | 100 | } |
101 | 101 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function isWriteable() |
110 | 110 | { |
111 | - if (! is_resource($this->handle)) { |
|
111 | + if (!is_resource($this->handle)) { |
|
112 | 112 | return false; |
113 | 113 | } |
114 | 114 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | |
132 | - if (! in_array($this->handle, $write)) { |
|
132 | + if (!in_array($this->handle, $write)) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $this->handle = $clientHandle; |
37 | 37 | $this->conntected = false; |
38 | 38 | |
39 | - if (! is_resource($clientHandle)) { |
|
39 | + if (!is_resource($clientHandle)) { |
|
40 | 40 | parent::__construct($endpoint); |
41 | 41 | } |
42 | 42 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function connect() |
50 | 50 | { |
51 | - if (! @socket_connect($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) { |
|
51 | + if (!@socket_connect($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) { |
|
52 | 52 | $code = socket_last_error($this->handle); |
53 | 53 | throw new SocketException(socket_strerror($code), array(), $code); |
54 | 54 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function disconnect() |
64 | 64 | { |
65 | - if (! $this->conntected) { |
|
65 | + if (!$this->conntected) { |
|
66 | 66 | throw new SocketException("Socket is not connected"); |
67 | 67 | } |
68 | 68 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public function __construct(Endpoint $endpoint) |
27 | 27 | { |
28 | 28 | parent::__construct($endpoint); |
29 | - if (! @socket_set_option($this->handle, SOL_SOCKET, SO_REUSEADDR, 1)) { |
|
29 | + if (!@socket_set_option($this->handle, SOL_SOCKET, SO_REUSEADDR, 1)) { |
|
30 | 30 | $code = socket_last_error($this->handle); |
31 | 31 | throw new SocketException(socket_strerror($code), array(), $code); |
32 | 32 | } |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | while ($runOn) { |
49 | 49 | $clientHandle = @socket_accept($this->handle); |
50 | 50 | |
51 | - if (! is_resource($clientHandle)) { |
|
51 | + if (!is_resource($clientHandle)) { |
|
52 | 52 | $code = socket_last_error($this->handle); |
53 | 53 | throw new SocketException(socket_strerror($code), array(), $code); |
54 | 54 | } |
55 | 55 | |
56 | 56 | $address = null; |
57 | 57 | $port = 0; |
58 | - if (! @socket_getpeername($clientHandle, $address, $port)) { |
|
58 | + if (!@socket_getpeername($clientHandle, $address, $port)) { |
|
59 | 59 | $code = socket_last_error($clientHandle); |
60 | 60 | throw new SocketException(socket_strerror($code), array(), $code); |
61 | 61 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | private function bind() |
75 | 75 | { |
76 | - if (! @socket_bind($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) { |
|
76 | + if (!@socket_bind($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) { |
|
77 | 77 | $code = socket_last_error($this->handle); |
78 | 78 | throw new SocketException(socket_strerror($code), array(), $code); |
79 | 79 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | private function listen() |
88 | 88 | { |
89 | - if (! @socket_listen($this->handle, 5)) { |
|
89 | + if (!@socket_listen($this->handle, 5)) { |
|
90 | 90 | $code = socket_last_error($this->handle); |
91 | 91 | throw new SocketException(socket_strerror($code), array(), $code); |
92 | 92 | } |