Passed
Pull Request — v3 (#536)
by
unknown
07:53
created

Rust::processDetails()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 14
ccs 7
cts 7
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * This file is part of GameQ.
4
 *
5
 * GameQ is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU Lesser General Public License as published by
7
 * the Free Software Foundation; either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * GameQ is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
namespace GameQ\Protocols;
20
21
use GameQ\Buffer;
22
use GameQ\Result;
23
24
/**
25
 * Class Rust
26
 *
27
 * @package GameQ\Protocols
28
 * @author  Austin Bischoff <[email protected]>
29
 */
30
class Rust extends Source
31
{
32
33
    /**
34
     * String name of this protocol class
35
     *
36
     * @type string
37
     */
38
    protected $name = 'rust';
39
40
    /**
41
     * Longer string name of this protocol class
42
     *
43
     * @type string
44
     */
45
    protected $name_long = "Rust";
46
    
47
    /**
48
     * Overload so we can get max players from mp of keywords and num players from cp keyword
49
     *
50
     * @param Buffer $buffer
51
     */
52 2
    protected function processDetails(Buffer $buffer)
53
    {
54
55 2
        $results = parent::processDetails($buffer);
56
        
57 2
        if($results['keywords'])
58
        {
59
            //get max players from mp of keywords and num players from cp keyword
60 2
            preg_match_all('/(mp|cp)([\d]+)/', $results['keywords'], $matches);
61 2
            $results['max_players'] = intval($matches[2][0]);
62 2
            $results['num_players'] = intval($matches[2][1]);
63
        }
64
65 2
        return $results;
66
          
67
    }
68
}
69