1 | <?php |
||
5 | trait HyperLogLogs |
||
6 | { |
||
7 | /** |
||
8 | * Adds the specified elements to the specified HyperLogLog. |
||
9 | * |
||
10 | * @param string $key |
||
11 | * @param array $elements |
||
12 | * |
||
13 | * @return int 1 if at least 1 HyperLogLog internal register |
||
14 | * was altered. 0 otherwise. |
||
15 | */ |
||
16 | public function pfAdd(string $key, array $elements): int |
||
20 | |||
21 | /** |
||
22 | * Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s). |
||
23 | * |
||
24 | * @param $keys |
||
25 | * |
||
26 | * @return int The approximated number of unique elements observed via pfAdd. |
||
27 | */ |
||
28 | public function pfCount(...$keys): int |
||
32 | |||
33 | /** |
||
34 | * Merge N different HyperLogLogs into a single one. |
||
35 | * |
||
36 | * @param string $destKey |
||
37 | * @param array $sourceKeys |
||
38 | * |
||
39 | * @return bool TRUE on success, FALSE on error. |
||
40 | */ |
||
41 | public function pfMerge(string $destKey, array $sourceKeys): bool |
||
45 | } |
||
46 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: