Conditions | 4 |
Paths | 8 |
Total Lines | 16 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
22 | public function value($value) |
||
23 | { |
||
24 | $result = $value; |
||
25 | $cnt = 1; |
||
26 | foreach ($this->values as $prev) { |
||
27 | $result += $prev; |
||
28 | ++$cnt; |
||
29 | } |
||
30 | if ($cnt > 1) { |
||
31 | $result /= $cnt; |
||
32 | } |
||
33 | if (count($this->values) >= $this->size) { |
||
34 | array_shift($this->values); |
||
35 | } |
||
36 | $this->values[] = $value; |
||
37 | return $result; |
||
38 | } |
||
39 | } |