@@ -57,8 +57,7 @@ |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | return $processedConfiguration; |
60 | - } |
|
61 | - else { |
|
60 | + } else { |
|
62 | 61 | throw new \RuntimeException(sprintf('Configuration file does not exist or is not accessible %s', |
63 | 62 | $this->filepath)); |
64 | 63 | } |
@@ -150,12 +150,10 @@ |
||
150 | 150 | if ($reflection->getConstructor()) { |
151 | 151 | $this->gauges[$path] = $reflection->newInstanceArgs( |
152 | 152 | $details['arguments'] ? $details['arguments'] : array()); |
153 | - } |
|
154 | - else { |
|
153 | + } else { |
|
155 | 154 | $this->gauges[$path] = $reflection->newInstance(); |
156 | 155 | } |
157 | - } |
|
158 | - else { |
|
156 | + } else { |
|
159 | 157 | throw new \RuntimeException(sprintf( |
160 | 158 | 'Class does not exists %s' |
161 | 159 | ), $className); |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | |
89 | 89 | $iterations = $input->getOption('iterations'); |
90 | 90 | $count = 0; |
91 | - while($count < $iterations) |
|
91 | + while ($count < $iterations) |
|
92 | 92 | { |
93 | - foreach($gauges as $path => $gauge) { |
|
93 | + foreach ($gauges as $path => $gauge) { |
|
94 | 94 | // Sampling period attained for current gauge? |
95 | 95 | if (fmod($count, $gauge->getSamplingPeriod()) == 0) { |
96 | 96 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $statsd->startBatch(); |
100 | 100 | |
101 | 101 | foreach ($values as $key => $value) { |
102 | - $composed = $path . '.' . $key; |
|
102 | + $composed = $path.'.'.$key; |
|
103 | 103 | |
104 | 104 | if (null !== $value) { |
105 | 105 | $statsd->gauge($composed, $value); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | sleep(1); |
118 | - $count ++; |
|
118 | + $count++; |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 |
@@ -124,9 +124,9 @@ |
||
124 | 124 | $input = $this->getInputInterface(); |
125 | 125 | |
126 | 126 | $map = array( |
127 | - [ 'statsd-host', 'localhost' ], |
|
128 | - [ 'statsd-port', '8125' ], |
|
129 | - [ 'statsd-namespace', 'test' ] |
|
127 | + ['statsd-host', 'localhost'], |
|
128 | + ['statsd-port', '8125'], |
|
129 | + ['statsd-namespace', 'test'] |
|
130 | 130 | ); |
131 | 131 | |
132 | 132 | $input->expects($this->atLeastOnce()) |
@@ -65,7 +65,7 @@ |
||
65 | 65 | foreach ($lines as $line) { |
66 | 66 | $data = explode(' ', $line); |
67 | 67 | array_walk($data, 'trim'); |
68 | - $stats[] = array_values(array_filter($data, function ($value) { |
|
68 | + $stats[] = array_values(array_filter($data, function($value) { |
|
69 | 69 | return strlen($value) > 0; |
70 | 70 | })); |
71 | 71 | } |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | $collection = new ValuesCollection(); |
64 | 64 | |
65 | 65 | foreach ($cpu as $name => $value) { |
66 | - $collection->add($name . '.cpu.value', $value); |
|
66 | + $collection->add($name.'.cpu.value', $value); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | foreach ($memory as $name => $value) { |
70 | - $collection->add($name . '.memory.value', $value); |
|
70 | + $collection->add($name.'.memory.value', $value); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | return $collection; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | protected function filterAbove($processes, $gate) |
96 | 96 | { |
97 | - return array_filter($processes, function ($item) use ($gate) { |
|
97 | + return array_filter($processes, function($item) use ($gate) { |
|
98 | 98 | return $item >= $gate; |
99 | 99 | }); |
100 | 100 | } |
@@ -111,8 +111,7 @@ discard block |
||
111 | 111 | foreach ($processes as $process) { |
112 | 112 | if (isset($cpus[$process->getName()])) { |
113 | 113 | $cpus[$process->getName()] += $process->getCpu(); |
114 | - } |
|
115 | - else { |
|
114 | + } else { |
|
116 | 115 | $cpus[$process->getName()] = $process->getCpu(); |
117 | 116 | } |
118 | 117 | } |
@@ -133,8 +132,7 @@ discard block |
||
133 | 132 | foreach ($processes as $process) { |
134 | 133 | if (isset($memory[$process->getName()])) { |
135 | 134 | $memory[$process->getName()] += $process->getMemory(); |
136 | - } |
|
137 | - else { |
|
135 | + } else { |
|
138 | 136 | $memory[$process->getName()] = $process->getMemory(); |
139 | 137 | } |
140 | 138 | } |
@@ -107,6 +107,7 @@ discard block |
||
107 | 107 | * Return only those processes above certail value |
108 | 108 | * |
109 | 109 | * @param $processes Process[] |
110 | + * @param double $gate |
|
110 | 111 | * @return array |
111 | 112 | */ |
112 | 113 | protected function filterAbove($processes, $gate) |
@@ -119,7 +120,7 @@ discard block |
||
119 | 120 | /** |
120 | 121 | * Aggregate CPU for processes with the same name |
121 | 122 | * |
122 | - * @param $processes Process[] |
|
123 | + * @param Process[] $processes Process[] |
|
123 | 124 | */ |
124 | 125 | protected function aggregateCpu($processes) |
125 | 126 | { |
@@ -140,7 +141,7 @@ discard block |
||
140 | 141 | /** |
141 | 142 | * Aggregate memory for processes with the same name |
142 | 143 | * |
143 | - * @param $processes Process[] |
|
144 | + * @param Process[] $processes Process[] |
|
144 | 145 | * @return array |
145 | 146 | */ |
146 | 147 | protected function aggregateMemory($processes) |
@@ -173,7 +174,7 @@ discard block |
||
173 | 174 | * Persist collection values to a temporary storage |
174 | 175 | * key is the command string value |
175 | 176 | * |
176 | - * @param $collection |
|
177 | + * @param ValuesCollection $collection |
|
177 | 178 | */ |
178 | 179 | protected function persistCollection($collection) |
179 | 180 | { |
@@ -210,7 +211,7 @@ discard block |
||
210 | 211 | * |
211 | 212 | * These are in fact previous collection values that needs to be sent to statsd as 0 |
212 | 213 | * |
213 | - * @param $collection |
|
214 | + * @param ValuesCollection $collection |
|
214 | 215 | */ |
215 | 216 | protected function resetValues($collection) { |
216 | 217 | foreach ($collection as $key => $value) { |
@@ -223,7 +224,7 @@ discard block |
||
223 | 224 | /** |
224 | 225 | * Remove empty values from collection |
225 | 226 | * |
226 | - * @param $collection |
|
227 | + * @param ValuesCollection $collection |
|
227 | 228 | */ |
228 | 229 | protected function removeEmpty($collection) { |
229 | 230 | foreach ($collection as $key => $value) { |
@@ -44,6 +44,6 @@ |
||
44 | 44 | $this->command = new RemoteTopCommand($this->sshString, $this->sshPort, $this->sshIdentityFile); |
45 | 45 | |
46 | 46 | |
47 | - $this->namespace = preg_replace('/[^-+_.A-Za-z0-9]*/i', '', 'statsd.' . $this->sshString . '.' . $this->sshPort); |
|
47 | + $this->namespace = preg_replace('/[^-+_.A-Za-z0-9]*/i', '', 'statsd.'.$this->sshString.'.'.$this->sshPort); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | \ No newline at end of file |