BotScoutResponse   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 0
dl 0
loc 81
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 4
A getMatched() 0 4 1
A getType() 0 4 1
A getAll() 0 4 1
A getMail() 0 4 1
A getIp() 0 4 1
A getName() 0 4 1
A getEvaluation() 0 4 1
A isValid() 0 4 1
1
<?php
2
3
namespace NicolasBeauvais\BotScout;
4
5
class BotScoutResponse
6
{
7
    protected $matched;
8
9
    protected $type;
10
11
    protected $all;
12
13
    protected $evaluation;
14
15
    protected $mail;
16
17
    protected $ip;
18
19
    protected $name;
20
21
    /**
22
     * BotScoutResponse constructor.
23
     */
24
    public function __construct($response)
25
    {
26
        $response = explode('|', $response);
27
28
        $this->matched = $response[0] === 'Y';
29
        $this->type = $response[1];
30
31
        if ($this->type === 'ALL') {
32
            $this->all = (int) $response[2];
33
            $this->evaluation = $response[3];
34
        } elseif ($this->type === 'MULTI') {
35
            $response = array_slice($response, 2);
36
            $count = count($response);
37
38
            for ($index = 0; $index < $count; $index += 2) {
39
                $this->{strtolower($response[$index])} = (int) $response[$index + 1];
40
            }
41
        } else {
42
            $this->{strtolower($this->type)} = (int) $response[2];
43
        }
44
    }
45
46
    public function getMatched() : bool
47
    {
48
        return $this->matched;
49
    }
50
51
    public function getType()
52
    {
53
        return $this->type;
54
    }
55
56
    public function getAll()
57
    {
58
        return $this->all;
59
    }
60
61
    public function getMail()
62
    {
63
        return $this->mail;
64
    }
65
66
    public function getIp()
67
    {
68
        return $this->ip;
69
    }
70
71
    public function getName()
72
    {
73
        return $this->name;
74
    }
75
76
    public function getEvaluation()
77
    {
78
        return $this->evaluation;
79
    }
80
81
    public function isValid() : bool
82
    {
83
        return ! $this->matched;
84
    }
85
}
86