@@ -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 | $count = $this->cache(__FUNCTION__, function() { |
| 34 | 34 | return $this->select(['COUNT(*)'])->where('entity=?')->prepare(); |
| 35 | 35 | }); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @param string $attribute |
| 45 | 45 | * @return bool |
| 46 | 46 | */ |
| 47 | - public function exists (int $id, string $attribute): bool { |
|
| 47 | + public function exists(int $id, string $attribute): bool { |
|
| 48 | 48 | $exists = $this->cache(__FUNCTION__, function() { |
| 49 | 49 | return $this->select(['COUNT(*) > 0'])->where('entity=:e AND attribute=:a')->prepare(); |
| 50 | 50 | }); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @param array $match `[attribute => value]`. If empty, selects all IDs for entities having at least one attribute. |
| 62 | 62 | * @return Select |
| 63 | 63 | */ |
| 64 | - public function find (array $match): Select { |
|
| 64 | + public function find(array $match): Select { |
|
| 65 | 65 | $select = $this->select([$this['entity']]); |
| 66 | 66 | $prior = $this; |
| 67 | 67 | foreach ($match as $attribute => $value) { |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param int $id |
| 84 | 84 | * @return array `[attribute => value]` |
| 85 | 85 | */ |
| 86 | - public function load (int $id): array { |
|
| 86 | + public function load(int $id): array { |
|
| 87 | 87 | $load = $this->cache(__FUNCTION__, function() { |
| 88 | 88 | return $this->select(['attribute', 'value'])->where('entity=?')->prepare(); |
| 89 | 89 | }); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param int[] $ids |
| 98 | 98 | * @return array[] `[id => attribute => value] |
| 99 | 99 | */ |
| 100 | - public function loadAll (array $ids): array { |
|
| 100 | + public function loadAll(array $ids): array { |
|
| 101 | 101 | if (count($ids) === 1) { |
| 102 | 102 | return [current($ids) => $this->load(current($ids))]; |
| 103 | 103 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * @param array $values `[attribute => value]` |
| 119 | 119 | * @return $this |
| 120 | 120 | */ |
| 121 | - public function save (int $id, array $values) { |
|
| 121 | + public function save(int $id, array $values) { |
|
| 122 | 122 | $this->delete([ |
| 123 | 123 | $this['entity']->isEqual($id), |
| 124 | 124 | $this['attribute']->isNotEqual(array_keys($values)) |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param string $name |
| 30 | 30 | * @param string $qualifier |
| 31 | 31 | */ |
| 32 | - public function __construct (DB $db, string $name, string $qualifier = '') { |
|
| 32 | + public function __construct(DB $db, string $name, string $qualifier = '') { |
|
| 33 | 33 | parent::__construct($db); |
| 34 | 34 | $this->name = $name; |
| 35 | 35 | $this->qualifier = $qualifier; |
@@ -40,21 +40,21 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return string |
| 42 | 42 | */ |
| 43 | - public function __toString (): string { |
|
| 43 | + public function __toString(): string { |
|
| 44 | 44 | return strlen($this->qualifier) ? "{$this->qualifier}.{$this->name}" : $this->name; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @return string |
| 49 | 49 | */ |
| 50 | - final public function getName (): string { |
|
| 50 | + final public function getName(): string { |
|
| 51 | 51 | return $this->name; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * @return string |
| 56 | 56 | */ |
| 57 | - final public function getQualifier (): string { |
|
| 57 | + final public function getQualifier(): string { |
|
| 58 | 58 | return $this->qualifier; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param null|bool|string|Select $arg |
| 68 | 68 | * @return string |
| 69 | 69 | */ |
| 70 | - public function is ($arg): string { |
|
| 70 | + public function is($arg): string { |
|
| 71 | 71 | if ($arg === null or is_bool($arg)) { |
| 72 | 72 | $arg = ['' => 'NULL', 1 => 'TRUE', 0 => 'FALSE'][$arg]; |
| 73 | 73 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param string|array|Select $arg |
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | - public function isEqual ($arg): string { |
|
| 84 | + public function isEqual($arg): string { |
|
| 85 | 85 | return SQL::isEqual($this, $this->db->quote($arg)); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string|Select $arg |
| 92 | 92 | * @return string |
| 93 | 93 | */ |
| 94 | - public function isGreater ($arg): string { |
|
| 94 | + public function isGreater($arg): string { |
|
| 95 | 95 | return SQL::isGreater($this, $this->db->quote($arg)); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @param string|Select $arg |
| 102 | 102 | * @return string |
| 103 | 103 | */ |
| 104 | - public function isGreaterOrEqual ($arg): string { |
|
| 104 | + public function isGreaterOrEqual($arg): string { |
|
| 105 | 105 | return SQL::isGreaterOrEqual($this, $this->db->quote($arg)); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param string|Select $arg |
| 112 | 112 | * @return string |
| 113 | 113 | */ |
| 114 | - public function isLess ($arg): string { |
|
| 114 | + public function isLess($arg): string { |
|
| 115 | 115 | return SQL::isLess($this, $this->db->quote($arg)); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param string|Select $arg |
| 122 | 122 | * @return string |
| 123 | 123 | */ |
| 124 | - public function isLessOrEqual ($arg): string { |
|
| 124 | + public function isLessOrEqual($arg): string { |
|
| 125 | 125 | return SQL::isLessOrEqual($this, $this->db->quote($arg)); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @param string $pattern |
| 132 | 132 | * @return string |
| 133 | 133 | */ |
| 134 | - public function isLike (string $pattern): string { |
|
| 134 | + public function isLike(string $pattern): string { |
|
| 135 | 135 | return SQL::isLike($this, $this->db->quote($pattern)); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @param null|bool|string|Select $arg |
| 144 | 144 | * @return string |
| 145 | 145 | */ |
| 146 | - public function isNot ($arg): string { |
|
| 146 | + public function isNot($arg): string { |
|
| 147 | 147 | return SQL::not($this->is($this->db->quote($arg))); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param string|array|Select $arg |
| 154 | 154 | * @return string |
| 155 | 155 | */ |
| 156 | - public function isNotEqual ($arg): string { |
|
| 156 | + public function isNotEqual($arg): string { |
|
| 157 | 157 | return SQL::isNotEqual($this, $this->db->quote($arg)); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @param string $pattern |
| 164 | 164 | * @return string |
| 165 | 165 | */ |
| 166 | - public function isNotLike (string $pattern): string { |
|
| 166 | + public function isNotLike(string $pattern): string { |
|
| 167 | 167 | return SQL::isNotLike($this, $this->db->quote($pattern)); |
| 168 | 168 | } |
| 169 | 169 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return string |
| 174 | 174 | */ |
| 175 | - public function isNotNull (): string { |
|
| 175 | + public function isNotNull(): string { |
|
| 176 | 176 | return SQL::isNotNull($this); |
| 177 | 177 | } |
| 178 | 178 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param string $pattern |
| 183 | 183 | * @return string |
| 184 | 184 | */ |
| 185 | - public function isNotRegExp (string $pattern): string { |
|
| 185 | + public function isNotRegExp(string $pattern): string { |
|
| 186 | 186 | return SQL::isNotRegExp($this, $this->db->quote($pattern)); |
| 187 | 187 | } |
| 188 | 188 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @param string $pattern |
| 193 | 193 | * @return string |
| 194 | 194 | */ |
| 195 | - public function isRegExp (string $pattern): string { |
|
| 195 | + public function isRegExp(string $pattern): string { |
|
| 196 | 196 | return SQL::isRegExp($this, $this->db->quote($pattern)); |
| 197 | 197 | } |
| 198 | 198 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @param string $name |
| 201 | 201 | * @return $this |
| 202 | 202 | */ |
| 203 | - public function setName (string $name) { |
|
| 203 | + public function setName(string $name) { |
|
| 204 | 204 | $clone = clone $this; |
| 205 | 205 | $clone->name = $name; |
| 206 | 206 | return $clone; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * @param string $qualifier |
| 211 | 211 | * @return $this |
| 212 | 212 | */ |
| 213 | - public function setQualifier (string $qualifier) { |
|
| 213 | + public function setQualifier(string $qualifier) { |
|
| 214 | 214 | $clone = clone $this; |
| 215 | 215 | $clone->qualifier = $qualifier; |
| 216 | 216 | return $clone; |
@@ -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('Columns cannot be altered by ArrayAccess.'); |
| 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 | |