@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param Record $record The entity's storage access. |
19 | 19 | * @param $name |
20 | 20 | */ |
21 | - public function __construct (Record $record, $name) { |
|
21 | + public function __construct(Record $record, $name) { |
|
22 | 22 | $this->record = $record; |
23 | 23 | parent::__construct($record->db, $name, ['entity', 'attribute', 'value']); |
24 | 24 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param int $id |
30 | 30 | * @return int |
31 | 31 | */ |
32 | - public function count (int $id): int { |
|
32 | + public function count(int $id): int { |
|
33 | 33 | return $this->cache(__FUNCTION__, function() { |
34 | 34 | return $this->select(['COUNT(*)'])->where('entity=?')->prepare(); |
35 | 35 | })->execute([$id])->fetchColumn(); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param string $attribute |
43 | 43 | * @return bool |
44 | 44 | */ |
45 | - public function exists (int $id, string $attribute): bool { |
|
45 | + public function exists(int $id, string $attribute): bool { |
|
46 | 46 | return $this->cache(__FUNCTION__, function() { |
47 | 47 | return $this->select(['COUNT(*) > 0'])->where('entity = ? AND attribute = ?')->prepare(); |
48 | 48 | })->execute([$id, $attribute])->fetchColumn(); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param array $match `[attribute => value]`. If empty, selects all IDs for entities having at least one attribute. |
58 | 58 | * @return Select |
59 | 59 | */ |
60 | - public function find (array $match): Select { |
|
60 | + public function find(array $match): Select { |
|
61 | 61 | $select = $this->select([$this['entity']]); |
62 | 62 | $prior = $this; |
63 | 63 | foreach ($match as $attribute => $value) { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param int $id |
80 | 80 | * @return array `[attribute => value]` |
81 | 81 | */ |
82 | - public function load (int $id): array { |
|
82 | + public function load(int $id): array { |
|
83 | 83 | return $this->cache(__FUNCTION__, function() { |
84 | 84 | return $this->select(['attribute', 'value'])->where('entity = ?')->prepare(); |
85 | 85 | })->execute([$id])->fetchAll(DB::FETCH_KEY_PAIR); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param int[] $ids |
92 | 92 | * @return array[] `[id => attribute => value] |
93 | 93 | */ |
94 | - public function loadAll (array $ids): array { |
|
94 | + public function loadAll(array $ids): array { |
|
95 | 95 | if (count($ids) === 1) { |
96 | 96 | return [current($ids) => $this->load(current($ids))]; |
97 | 97 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param array $values `[attribute => value]` |
112 | 112 | * @return $this |
113 | 113 | */ |
114 | - public function save (int $id, array $values) { |
|
114 | + public function save(int $id, array $values) { |
|
115 | 115 | $this->delete([ |
116 | 116 | $this['entity']->isEqual($id), |
117 | 117 | $this['attribute']->isNotEqual(array_keys($values)) |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param DB $db |
23 | 23 | */ |
24 | - protected function __construct (DB $db) { |
|
24 | + protected function __construct(DB $db) { |
|
25 | 25 | $this->db = $db; |
26 | 26 | } |
27 | 27 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return string |
32 | 32 | */ |
33 | - public function __toString () { |
|
33 | + public function __toString() { |
|
34 | 34 | return $this->queryString; |
35 | 35 | } |
36 | 36 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return $this |
45 | 45 | * @throws ArgumentCountError |
46 | 46 | */ |
47 | - public function execute ($args = null) { |
|
47 | + public function execute($args = null) { |
|
48 | 48 | $this->db->getLogger()->__invoke($this->queryString); |
49 | 49 | if (!parent::execute($args)) { |
50 | 50 | $info = $this->errorInfo(); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return int |
63 | 63 | */ |
64 | - public function getId (): int { |
|
64 | + public function getId(): int { |
|
65 | 65 | return $this->db->lastInsertId(); |
66 | 66 | } |
67 | 67 | } |
@@ -15,19 +15,19 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @return string |
17 | 17 | */ |
18 | - abstract public function __toString (): string; |
|
18 | + abstract public function __toString(): string; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @param string $name |
22 | 22 | * @return bool |
23 | 23 | */ |
24 | - abstract public function offsetExists ($name): bool; |
|
24 | + abstract public function offsetExists($name): bool; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @param string $name |
28 | 28 | * @return Column |
29 | 29 | */ |
30 | - abstract public function offsetGet ($name): Column; |
|
30 | + abstract public function offsetGet($name): Column; |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Throws. |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param void $value |
37 | 37 | * @throws Exception |
38 | 38 | */ |
39 | - final public function offsetSet ($name, $value): void { |
|
39 | + final public function offsetSet($name, $value): void { |
|
40 | 40 | throw new Exception('Tables are immutable.'); |
41 | 41 | } |
42 | 42 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param void $name |
47 | 47 | * @throws Exception |
48 | 48 | */ |
49 | - final public function offsetUnset ($name): void { |
|
49 | + final public function offsetUnset($name): void { |
|
50 | 50 | $this->offsetSet($name, null); |
51 | 51 | } |
52 | 52 |