Passed
Push — main ( 14357c...3c140b )
by smiley
01:53
created
src/TS3Client.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 use function fclose, fsockopen, fwrite, is_resource, restore_error_handler,
18 18
 	set_error_handler, stream_get_contents, stream_set_timeout, trim;
19 19
 
20
-class TS3Client implements LoggerAwareInterface{
20
+class TS3Client implements LoggerAwareInterface {
21 21
 	use LoggerAwareTrait;
22 22
 
23 23
 	/**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param \chillerlan\Settings\SettingsContainerInterface $config
37 37
 	 * @param \Psr\Log\LoggerInterface|null                   $logger
38 38
 	 */
39
-	public function __construct(SettingsContainerInterface $config, LoggerInterface $logger = null){
39
+	public function __construct(SettingsContainerInterface $config, LoggerInterface $logger = null) {
40 40
 		$this->config = $config;
41 41
 		$this->logger = $logger ?? new NullLogger;
42 42
 	}
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	/**
45 45
 	 *
46 46
 	 */
47
-	public function __destruct(){
47
+	public function __destruct() {
48 48
 		$this->disconnect();
49 49
 	}
50 50
 
@@ -53,19 +53,19 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function connect():TS3Client{
55 55
 
56
-		if(is_resource($this->socket)){
56
+		if (is_resource($this->socket)) {
57 57
 			return $this;
58 58
 		}
59 59
 
60 60
 		/** @phan-suppress-next-line PhanTypeMismatchArgumentInternal stupid inconsistent callables... */
61
-		set_error_handler(function($severity, $msg, $file, $line){
61
+		set_error_handler(function($severity, $msg, $file, $line) {
62 62
 			throw new ErrorException($msg, 0, $severity, $file, $line);
63 63
 		});
64 64
 
65
-		try{
65
+		try {
66 66
 			$this->socket = fsockopen($this->config->host, $this->config->port);
67 67
 		}
68
-		catch(Throwable $e){
68
+		catch (Throwable $e) {
69 69
 			throw new TS3ClientException('could not connect: #'.$e->getMessage());
70 70
 		}
71 71
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public function disconnect():TS3Client{
85 85
 
86
-		if(is_resource($this->socket)){
86
+		if (is_resource($this->socket)) {
87 87
 			$this->send('logout');
88 88
 			$this->send('quit');
89 89
 
@@ -104,18 +104,18 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public function send(string $command):TS3Response{
106 106
 
107
-		if(!$this->socket){
107
+		if (!$this->socket) {
108 108
 			throw new TS3ClientException('not connected');
109 109
 		}
110 110
 
111 111
 		$command = trim($command);
112 112
 		$this->logger->debug('command: '.$command);
113 113
 
114
-		if(empty($command)){
114
+		if (empty($command)) {
115 115
 			throw new TS3ClientException('empty command');
116 116
 		}
117 117
 
118
-		if(fwrite($this->socket, $command."\n") !== false){
118
+		if (fwrite($this->socket, $command."\n") !== false) {
119 119
 			$response = stream_get_contents($this->socket);
120 120
 
121 121
 			$this->logger->debug('response: '.$response);
Please login to merge, or discard this patch.