@@ -131,7 +131,7 @@ |
||
131 | 131 | if (\PEAR::isError($mail)) |
132 | 132 | { |
133 | 133 | $this->error( |
134 | - $mail->getCode(), $mail->getMessage() |
|
134 | + $mail->getCode(), $mail->getMessage() |
|
135 | 135 | ); |
136 | 136 | |
137 | 137 | return false; |
@@ -22,10 +22,10 @@ |
||
22 | 22 | * |
23 | 23 | * @var integer |
24 | 24 | */ |
25 | - const FILE_PERMISSION_DENIED = 1; |
|
26 | - const FILE_NOT_FOUND = 2; |
|
27 | - const FILE_EXISTS = 3; |
|
28 | - const NOT_DIRECTORY = 4; |
|
25 | + const FILE_PERMISSION_DENIED = 1; |
|
26 | + const FILE_NOT_FOUND = 2; |
|
27 | + const FILE_EXISTS = 3; |
|
28 | + const NOT_DIRECTORY = 4; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Common JSON errors |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param array $where |
24 | 24 | */ |
25 | - public function select(Array $where); |
|
25 | + public function select(Array $where); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Insert statement |
29 | 29 | * |
30 | 30 | * @param array $data |
31 | 31 | */ |
32 | - public function insert(Array $data); |
|
32 | + public function insert(Array $data); |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Update statement |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | * @param array $set |
38 | 38 | * @param array $where |
39 | 39 | */ |
40 | - public function update(Array $set, Array $where); |
|
40 | + public function update(Array $set, Array $where); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Delete statement |
44 | 44 | * |
45 | 45 | * @param array $where |
46 | 46 | */ |
47 | - public function delete(Array $where); |
|
47 | + public function delete(Array $where); |
|
48 | 48 | } |
49 | 49 | \ No newline at end of file |
@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return string |
28 | 28 | */ |
29 | - public function read($socket) |
|
30 | - { |
|
31 | - if (($message = @socket_read($socket, 1024)) === false) |
|
32 | - { |
|
33 | - $errno = socket_last_error(); |
|
34 | - $this->error($errno, socket_strerror($errno)); |
|
29 | + public function read($socket) |
|
30 | + { |
|
31 | + if (($message = @socket_read($socket, 1024)) === false) |
|
32 | + { |
|
33 | + $errno = socket_last_error(); |
|
34 | + $this->error($errno, socket_strerror($errno)); |
|
35 | 35 | |
36 | - throw new \RuntimeException("Could not read message from client socket"); |
|
37 | - } |
|
36 | + throw new \RuntimeException("Could not read message from client socket"); |
|
37 | + } |
|
38 | 38 | |
39 | - return $message; |
|
40 | - } |
|
39 | + return $message; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Sends a message to client socket |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return integer |
51 | 51 | */ |
52 | - public function send($socket, $message) |
|
53 | - { |
|
54 | - if (($bytes = @socket_write($socket, $message, strlen($message))) === false) |
|
55 | - { |
|
56 | - $errno = socket_last_error(); |
|
57 | - $this->error($errno, socket_strerror($errno)); |
|
52 | + public function send($socket, $message) |
|
53 | + { |
|
54 | + if (($bytes = @socket_write($socket, $message, strlen($message))) === false) |
|
55 | + { |
|
56 | + $errno = socket_last_error(); |
|
57 | + $this->error($errno, socket_strerror($errno)); |
|
58 | 58 | |
59 | - throw new \RuntimeException("Could not send message to the client socket"); |
|
60 | - } |
|
59 | + throw new \RuntimeException("Could not send message to the client socket"); |
|
60 | + } |
|
61 | 61 | |
62 | - return $bytes; |
|
63 | - } |
|
62 | + return $bytes; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Sets socket to listening |
@@ -71,54 +71,54 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return boolean |
73 | 73 | */ |
74 | - public function listen(Array $eventHandlers = array()) |
|
75 | - { |
|
76 | - $event = $eventHandlers; |
|
77 | - $clousure = function(){}; |
|
74 | + public function listen(Array $eventHandlers = array()) |
|
75 | + { |
|
76 | + $event = $eventHandlers; |
|
77 | + $clousure = function(){}; |
|
78 | 78 | |
79 | - if (!array_key_exists('success', $event)) |
|
80 | - $event["success"] = $clousure; |
|
79 | + if (!array_key_exists('success', $event)) |
|
80 | + $event["success"] = $clousure; |
|
81 | 81 | |
82 | - if (!array_key_exists('error', $event)) |
|
83 | - $event["error"] = $clousure; |
|
82 | + if (!array_key_exists('error', $event)) |
|
83 | + $event["error"] = $clousure; |
|
84 | 84 | |
85 | - $listener = false; |
|
85 | + $listener = false; |
|
86 | 86 | |
87 | - if (!($listener = @socket_listen($this->socket, 30))) |
|
88 | - { |
|
89 | - $errno = socket_last_error(); |
|
90 | - $this->error($errno, socket_strerror($errno)); |
|
87 | + if (!($listener = @socket_listen($this->socket, 30))) |
|
88 | + { |
|
89 | + $errno = socket_last_error(); |
|
90 | + $this->error($errno, socket_strerror($errno)); |
|
91 | 91 | |
92 | - throw new \RuntimeException("Could not set socket to listen"); |
|
93 | - } |
|
94 | - else { |
|
92 | + throw new \RuntimeException("Could not set socket to listen"); |
|
93 | + } |
|
94 | + else { |
|
95 | 95 | |
96 | - echo "\n"; |
|
97 | - echo "Server Started : " . date('Y-m-d H:i:s') . "\n"; |
|
98 | - echo "Master socket : " . $this->socket . "\n"; |
|
99 | - echo "Listening on : " . $this->host . " port " . $this->port . "\n\n"; |
|
96 | + echo "\n"; |
|
97 | + echo "Server Started : " . date('Y-m-d H:i:s') . "\n"; |
|
98 | + echo "Master socket : " . $this->socket . "\n"; |
|
99 | + echo "Listening on : " . $this->host . " port " . $this->port . "\n\n"; |
|
100 | 100 | |
101 | - $socket = $this->socket; |
|
101 | + $socket = $this->socket; |
|
102 | 102 | |
103 | - if (!($spawn = @socket_accept($this->socket))) |
|
104 | - { |
|
105 | - $errno = socket_last_error(); |
|
106 | - $this->error($errno, socket_strerror($errno)); |
|
103 | + if (!($spawn = @socket_accept($this->socket))) |
|
104 | + { |
|
105 | + $errno = socket_last_error(); |
|
106 | + $this->error($errno, socket_strerror($errno)); |
|
107 | 107 | |
108 | - throw new \RuntimeException("Could not accept incoming connection"); |
|
109 | - } |
|
108 | + throw new \RuntimeException("Could not accept incoming connection"); |
|
109 | + } |
|
110 | 110 | |
111 | - $input = $this->read($spawn); |
|
111 | + $input = $this->read($spawn); |
|
112 | 112 | |
113 | - $input = trim($input); |
|
114 | - call_user_func($event["success"], $input, $this, $spawn); |
|
113 | + $input = trim($input); |
|
114 | + call_user_func($event["success"], $input, $this, $spawn); |
|
115 | 115 | |
116 | - socket_close($spawn); |
|
117 | - } |
|
116 | + socket_close($spawn); |
|
117 | + } |
|
118 | 118 | |
119 | - if (!$listener) |
|
120 | - call_user_func($event["error"], $this->getLastError()); |
|
119 | + if (!$listener) |
|
120 | + call_user_func($event["error"], $this->getLastError()); |
|
121 | 121 | |
122 | - return $listener; |
|
123 | - } |
|
122 | + return $listener; |
|
123 | + } |
|
124 | 124 | } |
125 | 125 | \ No newline at end of file |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | $this->socket = $socket; |
124 | - } |
|
124 | + } |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Binds the socket |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @return null |
147 | 147 | */ |
148 | - public function close() |
|
149 | - { |
|
148 | + public function close() |
|
149 | + { |
|
150 | 150 | return socket_close($this->socket); |
151 | - } |
|
151 | + } |
|
152 | 152 | } |
153 | 153 | \ No newline at end of file |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | try |
241 | 241 | { |
242 | 242 | $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('Hello world!')"; |
243 | - $result = $conn->execute($sql); |
|
243 | + $result = $conn->execute($sql); |
|
244 | 244 | } |
245 | 245 | catch (\Exception $e) |
246 | 246 | { |
@@ -511,11 +511,11 @@ discard block |
||
511 | 511 | |
512 | 512 | try |
513 | 513 | { |
514 | - $sql = "INSERT INTO MYTABLE (DESCRIPTION) VALUES ('TRANS_SHORTCUT_1')"; |
|
515 | - $result = $conn->execute($sql); |
|
514 | + $sql = "INSERT INTO MYTABLE (DESCRIPTION) VALUES ('TRANS_SHORTCUT_1')"; |
|
515 | + $result = $conn->execute($sql); |
|
516 | 516 | |
517 | - $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('TRANS_SHORTCUT_2')"; |
|
518 | - $result = $conn->execute($sql); |
|
517 | + $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('TRANS_SHORTCUT_2')"; |
|
518 | + $result = $conn->execute($sql); |
|
519 | 519 | } |
520 | 520 | catch (InvalidQueryException $e) |
521 | 521 | { |
@@ -171,5 +171,5 @@ |
||
171 | 171 | 'foo2', // directory |
172 | 172 | 'foo4', // not a directory or file |
173 | 173 | true); |
174 | - } |
|
174 | + } |
|
175 | 175 | } |
176 | 176 | \ No newline at end of file |