Completed
Push — master ( 0cd2cd...e2ec22 )
by Sam
02:48
created
tests/Resolver/JsonResolverTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@
 block discarded – undo
23 23
     public function setUp()
24 24
     {
25 25
         $files = [
26
-            __DIR__.'/../Resources/example.com.json',
27
-            __DIR__.'/../Resources/test_records.json',
26
+            __DIR__ . '/../Resources/example.com.json',
27
+            __DIR__ . '/../Resources/test_records.json',
28 28
         ];
29 29
         $this->resolver = new JsonResolver($files, 300);
30 30
     }
Please login to merge, or discard this patch.
src/Encoder.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
     public static function encodeMessage(Message $message): string
24 24
     {
25 25
         return
26
-            self::encodeHeader($message->getHeader()).
27
-            self::encodeResourceRecords($message->getQuestions()).
28
-            self::encodeResourceRecords($message->getAnswers()).
29
-            self::encodeResourceRecords($message->getAuthoritatives()).
26
+            self::encodeHeader($message->getHeader()) .
27
+            self::encodeResourceRecords($message->getQuestions()) .
28
+            self::encodeResourceRecords($message->getAnswers()) .
29
+            self::encodeResourceRecords($message->getAuthoritatives()) .
30 30
             self::encodeResourceRecords($message->getAdditionals());
31 31
     }
32 32
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
             return chr(0);
44 44
         }
45 45
 
46
-        $domain = rtrim($domain, '.').'.';
46
+        $domain = rtrim($domain, '.') . '.';
47 47
         $res = '';
48 48
 
49 49
         foreach (explode('.', $domain) as $label) {
50
-            $res .= chr(strlen($label)).$label;
50
+            $res .= chr(strlen($label)) . $label;
51 51
         }
52 52
 
53 53
         return $res;
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
     {
79 79
         $encoded = self::encodeDomainName($rr->getName());
80 80
         if ($rr->isQuestion()) {
81
-            return $encoded.pack('nn', $rr->getType(), $rr->getClass());
81
+            return $encoded . pack('nn', $rr->getType(), $rr->getClass());
82 82
         }
83 83
 
84 84
         $data = RdataEncoder::encodeRdata($rr->getType(), $rr->getRdata());
85 85
         $encoded .= pack('nnNn', $rr->getType(), $rr->getClass(), $rr->getTtl(), strlen($data));
86 86
 
87
-        return $encoded.$data;
87
+        return $encoded . $data;
88 88
     }
89 89
 
90 90
     /**
Please login to merge, or discard this patch.
src/Event/Subscriber/EchoLogger.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,19 +44,19 @@
 block discarded – undo
44 44
     public function onQueryReceive(QueryReceiveEvent $event): void
45 45
     {
46 46
         foreach ($event->getMessage()->getQuestions() as $question) {
47
-            $this->log(LogLevel::INFO, 'Query: '.$question);
47
+            $this->log(LogLevel::INFO, 'Query: ' . $question);
48 48
         }
49 49
     }
50 50
 
51 51
     public function onQueryResponse(QueryResponseEvent $event): void
52 52
     {
53 53
         foreach ($event->getMessage()->getAnswers() as $answer) {
54
-            $this->log(LogLevel::INFO, 'Answer: '.$answer);
54
+            $this->log(LogLevel::INFO, 'Answer: ' . $answer);
55 55
         }
56 56
     }
57 57
 
58 58
     public function log($level, $message, array $context = [])
59 59
     {
60
-        echo sprintf('[%s] %s: %s'.PHP_EOL, date('c'), $level, $message);
60
+        echo sprintf('[%s] %s: %s' . PHP_EOL, date('c'), $level, $message);
61 61
     }
62 62
 }
Please login to merge, or discard this patch.
src/RdataEncoder.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     public static function soa(array $rdata): string
82 82
     {
83 83
         return
84
-            Encoder::encodeDomainName($rdata['mname']).
85
-            Encoder::encodeDomainName($rdata['rname']).
84
+            Encoder::encodeDomainName($rdata['mname']) .
85
+            Encoder::encodeDomainName($rdata['rname']) .
86 86
             pack(
87 87
                 'NNNNN',
88 88
                 $rdata['serial'],
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      */
102 102
     public static function mx(array $rdata): string
103 103
     {
104
-        return pack('n', (int) $rdata['preference']).Encoder::encodeDomainName($rdata['exchange']);
104
+        return pack('n', (int) $rdata['preference']) . Encoder::encodeDomainName($rdata['exchange']);
105 105
     }
106 106
 
107 107
     /**
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
     {
115 115
         $rdata = substr($rdata, 0, 255);
116 116
 
117
-        return chr(strlen($rdata)).$rdata;
117
+        return chr(strlen($rdata)) . $rdata;
118 118
     }
119 119
 
120 120
     /**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public static function srv(array $rdata): string
127 127
     {
128
-        return pack('nnn', (int) $rdata['priority'], (int) $rdata['weight'], (int) $rdata['port']).
128
+        return pack('nnn', (int) $rdata['priority'], (int) $rdata['weight'], (int) $rdata['port']) .
129 129
             Encoder::encodeDomainName($rdata['target']);
130 130
     }
131 131
 }
132 132
\ No newline at end of file
Please login to merge, or discard this patch.
src/Server.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -73,10 +73,10 @@
 block discarded – undo
73 73
 
74 74
         $this->loop = \React\EventLoop\Factory::create();
75 75
         $factory = new \React\Datagram\Factory($this->loop);
76
-        $factory->createServer($this->ip.':'.$this->port)->then(function (Socket $server) {
76
+        $factory->createServer($this->ip . ':' . $this->port)->then(function(Socket $server) {
77 77
             $this->dispatcher->dispatch(Events::SERVER_START, new ServerStartEvent($server));
78 78
             $server->on('message', [$this, 'onMessage']);
79
-        })->otherwise(function (\Exception $exception) {
79
+        })->otherwise(function(\Exception $exception) {
80 80
             $this->dispatcher->dispatch(Events::SERVER_START_FAIL, new ServerExceptionEvent($exception));
81 81
         });
82 82
     }
Please login to merge, or discard this patch.
tests/EncoderTest.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
     public function testEncodeDomainName()
25 25
     {
26 26
         $input_1 = 'www.example.com.';
27
-        $expectation_1 = chr(3).'www'.chr(7).'example'.chr(3).'com'."\0";
27
+        $expectation_1 = chr(3) . 'www' . chr(7) . 'example' . chr(3) . 'com' . "\0";
28 28
 
29 29
         $input_2 = '.';
30 30
         $expectation_2 = "\0";
31 31
 
32 32
         $input_3 = 'tld.';
33
-        $expectation_3 = chr(3).'tld'."\0";
33
+        $expectation_3 = chr(3) . 'tld' . "\0";
34 34
 
35 35
         $this->assertEquals($expectation_1, Encoder::encodeDomainName($input_1));
36 36
         $this->assertEquals($expectation_2, Encoder::encodeDomainName($input_2));
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
             ->setQuestion(true);
51 51
 
52 52
         $expectation_1 =
53
-            chr(3).'www'.chr(7).'example'.chr(3).'com'."\0".
53
+            chr(3) . 'www' . chr(7) . 'example' . chr(3) . 'com' . "\0" .
54 54
             pack('nn', 1, 1);
55 55
 
56 56
         $input_2 = [];
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
             ->setQuestion(2);
62 62
 
63 63
         $expectation_2 =
64
-            chr(6).'domain'.chr(3).'com'.chr(2).'au'."\0".
64
+            chr(6) . 'domain' . chr(3) . 'com' . chr(2) . 'au' . "\0" .
65 65
             pack('nn', 15, 1);
66 66
 
67 67
         $input_3 = [$input_1[0], $input_2[0]];
68
-        $expectation_3 = $expectation_1.$expectation_2;
68
+        $expectation_3 = $expectation_1 . $expectation_2;
69 69
 
70 70
         $this->assertEquals($expectation_1, Encoder::encodeResourceRecords($input_1));
71 71
         $this->assertEquals($expectation_2, Encoder::encodeResourceRecords($input_2));
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $type = RecordTypeEnum::TYPE_MX;
88 88
         $ipAddress = '192.163.5.2';
89 89
 
90
-        $rdata = pack('n', $preference).$exchangeEncoded;
90
+        $rdata = pack('n', $preference) . $exchangeEncoded;
91 91
         $rdata2 = inet_pton($ipAddress);
92 92
 
93 93
         $decoded1 = (new ResourceRecord())
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
             ->setType(RecordTypeEnum::TYPE_A)
106 106
             ->setRdata($ipAddress);
107 107
 
108
-        $encoded1 = $nameEncoded.pack('nnNn', $type, $class, $ttl, strlen($rdata)).$rdata;
109
-        $encoded2 = $nameEncoded.pack('nnNn', 1, $class, $ttl, strlen($rdata2)).$rdata2;
108
+        $encoded1 = $nameEncoded . pack('nnNn', $type, $class, $ttl, strlen($rdata)) . $rdata;
109
+        $encoded2 = $nameEncoded . pack('nnNn', 1, $class, $ttl, strlen($rdata2)) . $rdata2;
110 110
 
111 111
         $this->assertEquals($encoded1, Encoder::encodeResourceRecords([$decoded1]));
112 112
         $this->assertEquals($encoded2, Encoder::encodeResourceRecords([$decoded2]));
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         $encoded_2 = inet_pton($decoded_2);
125 125
 
126 126
         $decoded_5 = 'dns1.example.com.';
127
-        $encoded_5 = chr(4).'dns1'.chr(7).'example'.chr(3).'com'."\0";
127
+        $encoded_5 = chr(4) . 'dns1' . chr(7) . 'example' . chr(3) . 'com' . "\0";
128 128
 
129 129
         $decoded_6 = [
130 130
             'mname' => 'example.com.',
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
         ];
138 138
 
139 139
         $encoded_6 =
140
-            chr(7).'example'.chr(3).'com'."\0".
141
-            chr(10).'postmaster'.chr(7).'example'.chr(3).'com'."\0".
140
+            chr(7) . 'example' . chr(3) . 'com' . "\0" .
141
+            chr(10) . 'postmaster' . chr(7) . 'example' . chr(3) . 'com' . "\0" .
142 142
             pack('NNNNN', 1970010188, 1800, 7200, 10800, 3600);
143 143
 
144 144
         $decoded_7 = [
@@ -146,10 +146,10 @@  discard block
 block discarded – undo
146 146
             'exchange' => 'mail.example.com.',
147 147
         ];
148 148
 
149
-        $encoded_7 = pack('n', 15).chr(4).'mail'.chr(7).'example'.chr(3).'com'."\0";
149
+        $encoded_7 = pack('n', 15) . chr(4) . 'mail' . chr(7) . 'example' . chr(3) . 'com' . "\0";
150 150
 
151 151
         $decoded_8 = 'This is a comment.';
152
-        $encoded_8 = chr(18).$decoded_8;
152
+        $encoded_8 = chr(18) . $decoded_8;
153 153
 
154 154
         $this->assertEquals($encoded_1, RdataEncoder::encodeRdata(1, $decoded_1));
155 155
         $this->assertEquals($encoded_2, RdataEncoder::encodeRdata(28, $decoded_2));
Please login to merge, or discard this patch.
tests/DecoderTest.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
     public function testDecodeDomainName()
25 25
     {
26 26
         $decoded_1 = 'www.example.com.';
27
-        $encoded_1 = chr(3).'www'.chr(7).'example'.chr(3).'com'."\0";
27
+        $encoded_1 = chr(3) . 'www' . chr(7) . 'example' . chr(3) . 'com' . "\0";
28 28
 
29 29
         $decoded_2 = '.';
30 30
         $encoded_2 = "\0";
31 31
 
32 32
         $decoded_3 = 'tld.';
33
-        $encoded_3 = chr(3).'tld'."\0";
33
+        $encoded_3 = chr(3) . 'tld' . "\0";
34 34
 
35 35
         $offset = 0;
36 36
         $this->assertEquals($decoded_1, Decoder::decodeDomainName($encoded_1, $offset));
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             ->setQuestion(true);
54 54
 
55 55
         $encoded_1 =
56
-            chr(3).'www'.chr(7).'example'.chr(3).'com'."\0".
56
+            chr(3) . 'www' . chr(7) . 'example' . chr(3) . 'com' . "\0" .
57 57
             pack('nn', 1, 1);
58 58
 
59 59
         $decoded_2[] = (new ResourceRecord())
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
             ->setQuestion(true);
63 63
 
64 64
         $encoded_2 =
65
-            chr(6).'domain'.chr(3).'com'.chr(2).'au'."\0".
65
+            chr(6) . 'domain' . chr(3) . 'com' . chr(2) . 'au' . "\0" .
66 66
             pack('nn', 15, 1);
67 67
 
68 68
         $decoded_3 = [$decoded_1[0], $decoded_2[0]];
69
-        $encoded_3 = $encoded_1.$encoded_2;
69
+        $encoded_3 = $encoded_1 . $encoded_2;
70 70
 
71 71
         $offset = 0;
72 72
         $this->assertEquals($decoded_1, Decoder::decodeResourceRecords($encoded_1, 1, $offset, true));
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         $type = RecordTypeEnum::TYPE_MX;
92 92
         $ipAddress = '192.163.5.2';
93 93
 
94
-        $rdata = pack('n', $priority).$exchangeEncoded;
94
+        $rdata = pack('n', $priority) . $exchangeEncoded;
95 95
         $rdata2 = inet_pton($ipAddress);
96 96
 
97 97
         $decoded1[] = (new ResourceRecord())
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 
114 114
         $decoded3 = array_merge($decoded1, $decoded2);
115 115
 
116
-        $encoded1 = $nameEncoded.pack('nnNn', $type, $class, $ttl, strlen($rdata)).$rdata;
117
-        $encoded2 = $nameEncoded.pack('nnNn', 1, $class, $ttl, strlen($rdata2)).$rdata2;
118
-        $encoded3 = $encoded1.$encoded2;
116
+        $encoded1 = $nameEncoded . pack('nnNn', $type, $class, $ttl, strlen($rdata)) . $rdata;
117
+        $encoded2 = $nameEncoded . pack('nnNn', 1, $class, $ttl, strlen($rdata2)) . $rdata2;
118
+        $encoded3 = $encoded1 . $encoded2;
119 119
 
120 120
         $this->assertEquals($decoded1, Decoder::decodeResourceRecords($encoded1));
121 121
         $this->assertEquals($decoded2, Decoder::decodeResourceRecords($encoded2));
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         $encoded_2 = inet_pton($decoded_2);
135 135
 
136 136
         $decoded_5 = 'dns1.example.com.';
137
-        $encoded_5 = chr(4).'dns1'.chr(7).'example'.chr(3).'com'."\0";
137
+        $encoded_5 = chr(4) . 'dns1' . chr(7) . 'example' . chr(3) . 'com' . "\0";
138 138
 
139 139
         $decoded_6_prime = [
140 140
             'mname' => 'example.com.',
@@ -147,18 +147,18 @@  discard block
 block discarded – undo
147 147
         ];
148 148
 
149 149
         $encoded_6 =
150
-            chr(7).'example'.chr(3).'com'."\0".
151
-            chr(10).'postmaster'.chr(7).'example'.chr(3).'com'."\0".
150
+            chr(7) . 'example' . chr(3) . 'com' . "\0" .
151
+            chr(10) . 'postmaster' . chr(7) . 'example' . chr(3) . 'com' . "\0" .
152 152
             pack('NNNNN', 1970010188, 1800, 7200, 10800, 3600);
153 153
 
154
-        $encoded_7 = pack('n', 10).chr(4).'mail'.chr(7).'example'.chr(3).'com'."\0";
154
+        $encoded_7 = pack('n', 10) . chr(4) . 'mail' . chr(7) . 'example' . chr(3) . 'com' . "\0";
155 155
         $decoded_7_prime = [
156 156
             'preference' => 10,
157 157
             'exchange' => 'mail.example.com.',
158 158
         ];
159 159
 
160 160
         $decoded_8 = 'This is a comment.';
161
-        $encoded_8 = chr(strlen($decoded_8)).$decoded_8;
161
+        $encoded_8 = chr(strlen($decoded_8)) . $decoded_8;
162 162
 
163 163
         $this->assertEquals($decoded_1, RdataDecoder::decodeRdata(RecordTypeEnum::TYPE_A, $encoded_1));
164 164
         $this->assertEquals($decoded_2, RdataDecoder::decodeRdata(RecordTypeEnum::TYPE_AAAA, $encoded_2));
Please login to merge, or discard this patch.