MCPcopy Create free account
hub / github.com/MaterializeInc/demos / process

Method process

connection-examples/php/state.php:68–88  ·  view source on GitHub ↗
(Update $update)

Source from the content-addressed store, hash-verified

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) {

Callers 1

updateMethod · 0.95

Calls 2

getValueMethod · 0.80
getDiffMethod · 0.80

Tested by

no test coverage detected