Code Duplication    Length = 24-28 lines in 2 locations

src/DP/GameServer/MinecraftServerBundle/MinecraftQuery/MinecraftQuery.php 1 location

@@ 59-86 (lines=28) @@
56
        }
57
    }
58
    
59
    public function getChallenge()
60
    {
61
        if (!isset($this->challenge)) {      
62
            try {
63
                $sessionId = $this->generateSessionId();
64
                $this->socket->send($this->packetFactory->handshake($sessionId));
65
            
66
                $resp = $this->socket->recv();
67
                $data = $resp->extract(array(
68
                    'type' => 'byte', 
69
                    'sessionId' => 'long', 
70
                    'challenge' => 'string'
71
                ));
72
                
73
                if ($data['sessionId'] == $sessionId) {
74
                    $this->challenge = $data['challenge'];
75
                }
76
                else {
77
                    throw new Exception\SessionIdNotMatchException;
78
                }
79
            }
80
            catch (RecvTimeoutException $e) {
81
                throw new Exception\ServerTimeoutException;
82
            }
83
        }
84
        
85
        return $this->challenge;
86
    }
87
    
88
    public function getServerInfos()
89
    {

src/DP/GameServer/SteamServerBundle/SteamQuery/SteamQuery.php 1 location

@@ 207-230 (lines=24) @@
204
     * 
205
     * @return long
206
     */
207
    protected function getChallenge()
208
    {
209
        if (!isset($this->challenge)) {
210
            try {
211
                $packet = $this->packetFactory->A2S_SERVERQUERY_GETCHALLENGE();
212
                $this->socket->send($packet);
213
                $resp = $this->socket->recv();
214
215
                $data = $resp->extract(array(
216
                    'header' => 'byte', 
217
                    'challenge' => 'long', 
218
                ));
219
220
                if ($data['header'] == 65) {
221
                    $this->challenge = $data['challenge'];
222
                }
223
            }
224
            catch (RecvTimeoutException $e) {
225
                throw new ServerTimeoutException();
226
            }
227
        }
228
        
229
        return $this->challenge;
230
    }
231
    
232
    /**
233
     * Get players list