@@ -157,7 +157,7 @@ |
||
| 157 | 157 | * |
| 158 | 158 | * @param $packet_id |
| 159 | 159 | * @param $packet_type |
| 160 | - * @param $packet_body |
|
| 160 | + * @param string $packet_body |
|
| 161 | 161 | * |
| 162 | 162 | * @return void |
| 163 | 163 | */ |
@@ -12,7 +12,8 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | namespace Thedudeguy; |
| 14 | 14 | |
| 15 | -class Rcon { |
|
| 15 | +class Rcon |
|
| 16 | +{ |
|
| 16 | 17 | private $host; |
| 17 | 18 | private $port; |
| 18 | 19 | private $password; |
@@ -39,7 +40,7 @@ discard block |
||
| 39 | 40 | * @param string $password |
| 40 | 41 | * @param integer $timeout |
| 41 | 42 | */ |
| 42 | - public function __construct($host, $port, $password, $timeout) |
|
| 43 | + public function __construct($host, $port, $password, $timeout) |
|
| 43 | 44 | { |
| 44 | 45 | $this->host = $host; |
| 45 | 46 | $this->port = $port; |
@@ -52,7 +53,7 @@ discard block |
||
| 52 | 53 | * |
| 53 | 54 | * @return string |
| 54 | 55 | */ |
| 55 | - public function getResponse() |
|
| 56 | + public function getResponse() |
|
| 56 | 57 | { |
| 57 | 58 | return $this->last_response; |
| 58 | 59 | } |
@@ -62,7 +63,7 @@ discard block |
||
| 62 | 63 | * |
| 63 | 64 | * @return boolean |
| 64 | 65 | */ |
| 65 | - public function connect() |
|
| 66 | + public function connect() |
|
| 66 | 67 | { |
| 67 | 68 | $this->socket = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout); |
| 68 | 69 | |
@@ -75,8 +76,9 @@ discard block |
||
| 75 | 76 | stream_set_timeout($this->socket, 3, 0); |
| 76 | 77 | |
| 77 | 78 | // check authorization |
| 78 | - if ($this->authorize()) |
|
| 79 | - return true; |
|
| 79 | + if ($this->authorize()) { |
|
| 80 | + return true; |
|
| 81 | + } |
|
| 80 | 82 | |
| 81 | 83 | return false; |
| 82 | 84 | } |
@@ -86,10 +88,11 @@ discard block |
||
| 86 | 88 | * |
| 87 | 89 | * @return void |
| 88 | 90 | */ |
| 89 | - public function disconnect() |
|
| 91 | + public function disconnect() |
|
| 90 | 92 | { |
| 91 | - if ($this->socket) |
|
| 92 | - fclose($this->socket); |
|
| 93 | + if ($this->socket) { |
|
| 94 | + fclose($this->socket); |
|
| 95 | + } |
|
| 93 | 96 | } |
| 94 | 97 | |
| 95 | 98 | /** |
@@ -97,7 +100,7 @@ discard block |
||
| 97 | 100 | * |
| 98 | 101 | * @return boolean |
| 99 | 102 | */ |
| 100 | - public function isConnected() |
|
| 103 | + public function isConnected() |
|
| 101 | 104 | { |
| 102 | 105 | return $this->authorized; |
| 103 | 106 | } |
@@ -109,10 +112,11 @@ discard block |
||
| 109 | 112 | * |
| 110 | 113 | * @return boolean|mixed |
| 111 | 114 | */ |
| 112 | - public function sendCommand($command) |
|
| 115 | + public function sendCommand($command) |
|
| 113 | 116 | { |
| 114 | - if (!$this->isConnected()) |
|
| 115 | - return false; |
|
| 117 | + if (!$this->isConnected()) { |
|
| 118 | + return false; |
|
| 119 | + } |
|
| 116 | 120 | |
| 117 | 121 | // send command packet |
| 118 | 122 | $this->writePacket(Rcon::PACKET_COMMAND, Rcon::SERVERDATA_EXECCOMMAND, $command); |
@@ -135,7 +139,7 @@ discard block |
||
| 135 | 139 | * |
| 136 | 140 | * @return boolean |
| 137 | 141 | */ |
| 138 | - private function authorize() |
|
| 142 | + private function authorize() |
|
| 139 | 143 | { |
| 140 | 144 | $this->writePacket(Rcon::PACKET_AUTHORIZE, Rcon::SERVERDATA_AUTH, $this->password); |
| 141 | 145 | $response_packet = $this->readPacket(); |
@@ -191,7 +195,7 @@ discard block |
||
| 191 | 195 | * |
| 192 | 196 | * @return array |
| 193 | 197 | */ |
| 194 | - private function readPacket() |
|
| 198 | + private function readPacket() |
|
| 195 | 199 | { |
| 196 | 200 | //get packet size. |
| 197 | 201 | $size_data = fread($this->socket, 4); |
@@ -234,7 +238,7 @@ discard block |
||
| 234 | 238 | * @deprecated |
| 235 | 239 | * @see Rcon::sendCommand() |
| 236 | 240 | */ |
| 237 | - public function send_command($command) |
|
| 241 | + public function send_command($command) |
|
| 238 | 242 | { |
| 239 | 243 | return $this->sendCommand($command); |
| 240 | 244 | } |