-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValueSet.php
More file actions
executable file
·44 lines (35 loc) · 878 Bytes
/
ValueSet.php
File metadata and controls
executable file
·44 lines (35 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php declare(strict_types=1);
namespace Parable\Query;
class ValueSet
{
protected array $values = [];
public function __construct(array $values = [])
{
foreach ($values as $key => $value) {
$this->addValue($key, $value);
}
}
public function addValue(string $key, $value): self
{
if (!is_scalar($value) && !is_null($value)) {
throw new QueryException(sprintf(
'Value is of invalid type: %s',
gettype($value)
));
}
$this->values[$key] = $value;
return $this;
}
public function getValues(): array
{
return $this->values;
}
public function getKeys(): array
{
return array_keys($this->values);
}
public function hasValues(): bool
{
return count($this->values) > 0;
}
}