| 66 | } |
| 67 | |
| 68 | public function process(Update $update) { |
| 69 | $value = json_encode($update->getValue()); |
| 70 | $diff = $update->getDiff(); |
| 71 | |
| 72 | if (isset($this->state[$value])) { |
| 73 | $count = $this->state[$value] + $diff; |
| 74 | } else { |
| 75 | $count = $diff; |
| 76 | } |
| 77 | |
| 78 | if ($count <= 0) { |
| 79 | unset($this->state[$value]); |
| 80 | } else { |
| 81 | $this->state[$value] = $count; |
| 82 | } |
| 83 | |
| 84 | // Add the update to the history array |
| 85 | if ($this->history !== null) { |
| 86 | $this->history[] = $update; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | public function update($updates, $timestamp) { |
| 91 | if (count($updates) > 0) { |