FullStorage   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 153
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 153
rs 10
c 0
b 0
f 0
wmc 17
lcom 1
cbo 1

14 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A addDetail() 0 19 4
A addInformation() 0 4 1
A addScoreboard() 0 4 1
A addStatistic() 0 4 1
A clear() 0 8 1
A getListOfDetail() 0 4 1
A getListOfInformation() 0 4 1
A getListOfScoreboard() 0 4 1
A getListOfStatistic() 0 4 1
A hasListOfDetail() 0 4 1
A hasListOfInformation() 0 4 1
A hasListOfScoreboard() 0 4 1
A hasListOfStatistic() 0 4 1
1
<?php
2
/**
3
 * @author stev leibelt <[email protected]>
4
 * @since 2017-02-01
5
 */
6
namespace Net\Bazzline\Component\ApacheServerStatusParser\Service\Content\Storage;
7
8
use JonasRudolph\PHPComponents\StringUtility\Implementation\StringUtility;
9
10
class FullStorage implements StorageInterface
11
{
12
    /** @var null|int */
13
    private $currentIndexKeyForListOfDetail;
14
15
    /** @var array */
16
    private $listOfDetail;
17
18
    /** @var array */
19
    private $listOfInformation;
20
21
    /** @var array */
22
    private $listOfScoreboard;
23
24
    /** @var array */
25
    private $listOfStatistic;
26
27
    /** @var StringUtility */
28
    private $stringUtility;
29
30
    /**
31
     * ContentCollection constructor.
32
     *
33
     * @param StringUtility $stringUtility
34
     */
35
    public function __construct(
36
        StringUtility $stringUtility
37
    ) {
38
        $this->clear();
39
40
        $this->stringUtility = $stringUtility;
41
    }
42
43
    /**
44
     * @param string $line
45
     */
46
    public function addDetail($line)
47
    {
48
        //@todo why? - Isn't this a job for the parser?
49
        $stringTool = $this->stringUtility;
50
51
        if (is_null($this->currentIndexKeyForListOfDetail)) {
52
            ++$this->currentIndexKeyForListOfDetail;
53
        } else {
54
            if ($stringTool->startsWith($line, 'Server')) {
55
                ++$this->currentIndexKeyForListOfDetail;
56
            }
57
        }
58
59
        if (isset($this->listOfDetail[$this->currentIndexKeyForListOfDetail])) {
60
            $this->listOfDetail[$this->currentIndexKeyForListOfDetail] .= $line;
61
        } else {
62
            $this->listOfDetail[$this->currentIndexKeyForListOfDetail] = $line;
63
        }
64
    }
65
66
    /**
67
     * @param string $line
68
     */
69
    public function addInformation($line)
70
    {
71
        $this->listOfInformation[] = $line;
72
    }
73
74
    /**
75
     * @param string $line
76
     */
77
    public function addScoreboard($line)
78
    {
79
        $this->listOfScoreboard[] = $line;
80
    }
81
82
    /**
83
     * @param string $line
84
     */
85
    public function addStatistic($line)
86
    {
87
        $this->listOfStatistic[] = $line;
88
    }
89
90
    public function clear()
91
    {
92
        $this->currentIndexKeyForListOfDetail   = null;
93
        $this->listOfDetail                     = [];
94
        $this->listOfInformation                = [];
95
        $this->listOfScoreboard                 = [];
96
        $this->listOfStatistic                  = [];
97
    }
98
99
    /**
100
     * @return array
101
     */
102
    public function getListOfDetail()
103
    {
104
        return $this->listOfDetail;
105
    }
106
107
    /**
108
     * @return array
109
     */
110
    public function getListOfInformation()
111
    {
112
        return $this->listOfInformation;
113
    }
114
115
    /**
116
     * @return array
117
     */
118
    public function getListOfScoreboard()
119
    {
120
        return $this->listOfScoreboard;
121
    }
122
123
    /**
124
     * @return array
125
     */
126
    public function getListOfStatistic()
127
    {
128
        return $this->listOfStatistic;
129
    }
130
131
    /**
132
     * @return boolean
133
     */
134
    public function hasListOfDetail()
135
    {
136
        return (!empty($this->listOfDetail));
137
    }
138
139
    /**
140
     * @return boolean
141
     */
142
    public function hasListOfInformation()
143
    {
144
        return (!empty($this->listOfInformation));
145
    }
146
147
    /**
148
     * @return boolean
149
     */
150
    public function hasListOfScoreboard()
151
    {
152
        return (!empty($this->listOfScoreboard));
153
    }
154
155
    /**
156
     * @return boolean
157
     */
158
    public function hasListOfStatistic()
159
    {
160
        return (!empty($this->listOfStatistic));
161
    }
162
}
163