@@ -24,6 +24,6 @@ |
||
| 24 | 24 | * @property string $filename |
| 25 | 25 | * @property string $apiversion |
| 26 | 26 | */ |
| 27 | -class TS3Config extends ContainerAbstract{ |
|
| 27 | +class TS3Config extends ContainerAbstract { |
|
| 28 | 28 | use TS3ConfigTrait; |
| 29 | 29 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @method void servertemppasswordadd($params = ['pw' => 'password', 'desc' => 'description']) |
| 137 | 137 | * @method void servertemppassworddel($params = ['pw' => 'password']) |
| 138 | 138 | */ |
| 139 | -class TS3QueryAPI extends TS3Client{ |
|
| 139 | +class TS3QueryAPI extends TS3Client { |
|
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | 142 | * @var \stdClass |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @param \chillerlan\Traits\ContainerInterface $config |
| 150 | 150 | */ |
| 151 | - public function __construct(ContainerInterface $config){ |
|
| 151 | + public function __construct(ContainerInterface $config) { |
|
| 152 | 152 | parent::__construct($config); |
| 153 | 153 | $this->connect(); |
| 154 | 154 | $this->map_api(); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | protected function map_api():TS3QueryAPI { |
| 162 | 162 | $file = $this->config->storagedir.$this->config->filename.'-'.$this->config->apiversion.'.json'; |
| 163 | 163 | |
| 164 | - if(!is_file($file)){ |
|
| 164 | + if (!is_file($file)) { |
|
| 165 | 165 | throw new TS3ClientException('please create a helpfile first'); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -179,23 +179,23 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function __call(string $method, array $arguments):TS3Response { |
| 181 | 181 | |
| 182 | - if(isset($this->methods->{$method})){ |
|
| 182 | + if (isset($this->methods->{$method})) { |
|
| 183 | 183 | $m = $this->methods->{$method}; |
| 184 | 184 | $args = []; |
| 185 | 185 | |
| 186 | - if(!empty($m->params) && is_array($arguments[0]) && !empty($arguments[0])){ |
|
| 186 | + if (!empty($m->params) && is_array($arguments[0]) && !empty($arguments[0])) { |
|
| 187 | 187 | |
| 188 | - foreach($arguments[0] as $k => $param){ |
|
| 188 | + foreach ($arguments[0] as $k => $param) { |
|
| 189 | 189 | |
| 190 | - if(is_int($k)){ |
|
| 190 | + if (is_int($k)) { |
|
| 191 | 191 | |
| 192 | - if(isset($m->params->{$param}) && !is_null($m->params->{$param}->value)){ |
|
| 192 | + if (isset($m->params->{$param}) && !is_null($m->params->{$param}->value)) { |
|
| 193 | 193 | throw new TS3ClientException('parameter value '.$param.'='.$m->params->{$param}->value.' not set'); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | $args[] = '-'.$param; |
| 197 | 197 | } |
| 198 | - else{ |
|
| 198 | + else { |
|
| 199 | 199 | $args[] = '-'.$k.'='.$param; |
| 200 | 200 | } |
| 201 | 201 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\Teamspeak; |
| 14 | 14 | |
| 15 | -trait TS3ConfigTrait{ |
|
| 15 | +trait TS3ConfigTrait { |
|
| 16 | 16 | |
| 17 | 17 | public $host = 'localhost'; |
| 18 | 18 | public $port = 10011; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * |
| 19 | 19 | */ |
| 20 | -class TS3Client{ |
|
| 20 | +class TS3Client { |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * @var \chillerlan\Teamspeak\TS3Config |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @param \chillerlan\Traits\ContainerInterface $config |
| 36 | 36 | */ |
| 37 | - public function __construct(ContainerInterface $config){ |
|
| 37 | + public function __construct(ContainerInterface $config) { |
|
| 38 | 38 | $this->config = $config; |
| 39 | 39 | |
| 40 | - if(!is_int($this->config->vserver)){ |
|
| 40 | + if (!is_int($this->config->vserver)) { |
|
| 41 | 41 | $this->config->vserver = 1; |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | /** |
| 46 | 46 | * |
| 47 | 47 | */ |
| 48 | - public function __destruct(){ |
|
| 48 | + public function __destruct() { |
|
| 49 | 49 | return $this->disconnect(); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | * @throws \chillerlan\Teamspeak\TS3ClientException |
| 55 | 55 | */ |
| 56 | 56 | public function connect():array { |
| 57 | - $this->socket = @fsockopen($this->config->host, $this->config->port, $errno, $errstr,3); |
|
| 57 | + $this->socket = @fsockopen($this->config->host, $this->config->port, $errno, $errstr, 3); |
|
| 58 | 58 | |
| 59 | - if(!$this->socket){ |
|
| 59 | + if (!$this->socket) { |
|
| 60 | 60 | throw new TS3ClientException('could not connect: #'.$errno.' '.$errstr); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function disconnect():array { |
| 75 | 75 | |
| 76 | - if($this->socket){ |
|
| 76 | + if ($this->socket) { |
|
| 77 | 77 | $r = [ |
| 78 | 78 | $this->send('logout'), |
| 79 | 79 | $this->send('quit'), |
@@ -98,17 +98,17 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function send(string $command):TS3Response { |
| 100 | 100 | |
| 101 | - if(!$this->socket){ |
|
| 101 | + if (!$this->socket) { |
|
| 102 | 102 | throw new TS3ClientException('not connected'); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $command = trim($command); |
| 106 | 106 | |
| 107 | - if(empty($command)){ |
|
| 107 | + if (empty($command)) { |
|
| 108 | 108 | throw new TS3ClientException('empty command'); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if(fwrite($this->socket, $command.PHP_EOL) !== false){ |
|
| 111 | + if (fwrite($this->socket, $command.PHP_EOL) !== false) { |
|
| 112 | 112 | return new TS3Response($command, stream_get_contents($this->socket)); |
| 113 | 113 | } |
| 114 | 114 | |