Passed
Push — main ( 3c140b...f1678e )
by smiley
02:52
created
src/TS3Client.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 use function implode;
20 20
 use function is_int;
21 21
 
22
-class TS3Client implements LoggerAwareInterface{
22
+class TS3Client implements LoggerAwareInterface {
23 23
 	use LoggerAwareTrait;
24 24
 
25 25
 	/**
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param \chillerlan\Settings\SettingsContainerInterface $config
39 39
 	 * @param \Psr\Log\LoggerInterface|null                   $logger
40 40
 	 */
41
-	public function __construct(SettingsContainerInterface $config, LoggerInterface $logger = null){
41
+	public function __construct(SettingsContainerInterface $config, LoggerInterface $logger = null) {
42 42
 		$this->config = $config;
43 43
 		$this->logger = $logger ?? new NullLogger;
44 44
 	}
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 *
48 48
 	 */
49
-	public function __destruct(){
49
+	public function __destruct() {
50 50
 		$this->disconnect();
51 51
 	}
52 52
 
@@ -55,19 +55,19 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function connect():TS3Client{
57 57
 
58
-		if(is_resource($this->socket)){
58
+		if (is_resource($this->socket)) {
59 59
 			return $this;
60 60
 		}
61 61
 
62 62
 		/** @phan-suppress-next-line PhanTypeMismatchArgumentInternal stupid inconsistent callables... */
63
-		set_error_handler(function($severity, $msg, $file, $line){
63
+		set_error_handler(function($severity, $msg, $file, $line) {
64 64
 			throw new ErrorException($msg, 0, $severity, $file, $line);
65 65
 		});
66 66
 
67
-		try{
67
+		try {
68 68
 			$this->socket = fsockopen($this->config->host, $this->config->port);
69 69
 		}
70
-		catch(Throwable $e){
70
+		catch (Throwable $e) {
71 71
 			throw new TS3ClientException('could not connect: #'.$e->getMessage());
72 72
 		}
73 73
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function disconnect():TS3Client{
91 91
 
92
-		if(is_resource($this->socket)){
92
+		if (is_resource($this->socket)) {
93 93
 			$this->send('logout');
94 94
 			$this->send('quit');
95 95
 
@@ -107,20 +107,20 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function send(string $command, array $params = null):TS3Response{
109 109
 
110
-		if(!$this->socket){
110
+		if (!$this->socket) {
111 111
 			throw new TS3ClientException('not connected');
112 112
 		}
113 113
 
114 114
 		$command = trim($command);
115 115
 
116
-		if(empty($command)){
116
+		if (empty($command)) {
117 117
 			throw new TS3ClientException('empty command');
118 118
 		}
119 119
 
120
-		if(!empty($params)){
120
+		if (!empty($params)) {
121 121
 			$args = [];
122 122
 
123
-			foreach($params as $k => $param){
123
+			foreach ($params as $k => $param) {
124 124
 				$args[] = is_int($k)
125 125
 					? '-'.trim($param)
126 126
 					: trim($k).'='.$param;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
 		$this->logger->debug('command: '.$command);
133 133
 
134
-		if(fwrite($this->socket, $command."\n") !== false){
134
+		if (fwrite($this->socket, $command."\n") !== false) {
135 135
 			$response = stream_get_contents($this->socket);
136 136
 
137 137
 			$this->logger->debug('response: '.$response);
Please login to merge, or discard this patch.