@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param string $passwd |
48 | 48 | * @param array $options |
49 | 49 | */ |
50 | - public function __construct ($dsn, $username = null, $passwd = null, $options = null) { |
|
50 | + public function __construct($dsn, $username = null, $passwd = null, $options = null) { |
|
51 | 51 | parent::__construct(...func_get_args()); |
52 | 52 | $this->setAttribute(self::ATTR_ERRMODE, self::ERRMODE_EXCEPTION); |
53 | 53 | $this->setAttribute(self::ATTR_DEFAULT_FETCH_MODE, self::FETCH_ASSOC); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param string $sql |
64 | 64 | * @return int |
65 | 65 | */ |
66 | - public function exec ($sql) { |
|
66 | + public function exec($sql) { |
|
67 | 67 | $this->logger->__invoke($sql); |
68 | 68 | return parent::exec($sql); |
69 | 69 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string |
75 | 75 | */ |
76 | - final public function getDriver () { |
|
76 | + final public function getDriver() { |
|
77 | 77 | return $this->getAttribute(self::ATTR_DRIVER_NAME); |
78 | 78 | } |
79 | 79 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param string $interface |
84 | 84 | * @return Junction |
85 | 85 | */ |
86 | - public function getJunction ($interface) { |
|
86 | + public function getJunction($interface) { |
|
87 | 87 | if (!isset($this->junctions[$interface])) { |
88 | 88 | $this->junctions[$interface] = new Junction($this, $interface); |
89 | 89 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param string|EntityInterface $class |
97 | 97 | * @return Record |
98 | 98 | */ |
99 | - public function getRecord ($class) { |
|
99 | + public function getRecord($class) { |
|
100 | 100 | if (is_object($class)) { |
101 | 101 | $class = get_class($class); |
102 | 102 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param string|array|Select|Closure $b |
129 | 129 | * @return string|string[] Same type as `$a`, keys are not preserved. |
130 | 130 | */ |
131 | - public function match ($a, $b = null) { |
|
131 | + public function match($a, $b = null) { |
|
132 | 132 | if (is_array($a)) { |
133 | 133 | return array_map([$this, __FUNCTION__], array_keys($a), $a); |
134 | 134 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @param string $access Class or interface name. |
146 | 146 | * @return bool |
147 | 147 | */ |
148 | - public function offsetExists ($access) { |
|
148 | + public function offsetExists($access) { |
|
149 | 149 | return (bool)$this->offsetGet($access); |
150 | 150 | } |
151 | 151 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param string $access Class or interface name. |
154 | 154 | * @return Record|Junction|null |
155 | 155 | */ |
156 | - public function offsetGet ($access) { |
|
156 | + public function offsetGet($access) { |
|
157 | 157 | if (class_exists($access)) { |
158 | 158 | return $this->getRecord($access); |
159 | 159 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param void $value |
171 | 171 | * @throws LogicException |
172 | 172 | */ |
173 | - final public function offsetSet ($access, $value) { |
|
173 | + final public function offsetSet($access, $value) { |
|
174 | 174 | throw new LogicException('The schema cannot be altered by ArrayAccess.'); |
175 | 175 | } |
176 | 176 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param void $access |
181 | 181 | * @throws LogicException |
182 | 182 | */ |
183 | - final public function offsetUnset ($access) { |
|
183 | + final public function offsetUnset($access) { |
|
184 | 184 | $this->offsetSet($access, null); |
185 | 185 | } |
186 | 186 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param array $options |
192 | 192 | * @return PDOStatement |
193 | 193 | */ |
194 | - public function prepare ($sql, $options = null) { |
|
194 | + public function prepare($sql, $options = null) { |
|
195 | 195 | $this->logger->__invoke($sql); |
196 | 196 | return parent::prepare(...func_get_args()); |
197 | 197 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @param array $ctorargs |
206 | 206 | * @return PDOStatement |
207 | 207 | */ |
208 | - public function query ($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) { |
|
208 | + public function query($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) { |
|
209 | 209 | $this->logger->__invoke($sql); |
210 | 210 | return parent::query(...func_get_args()); |
211 | 211 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @param int $type Ignored. |
229 | 229 | * @return mixed |
230 | 230 | */ |
231 | - public function quote ($value, $type = null) { |
|
231 | + public function quote($value, $type = null) { |
|
232 | 232 | if ($value instanceof Column) { |
233 | 233 | return (string)$value; |
234 | 234 | } |
@@ -253,14 +253,14 @@ discard block |
||
253 | 253 | * @param EntityInterface $entity |
254 | 254 | * @return int ID |
255 | 255 | */ |
256 | - public function save (EntityInterface $entity) { |
|
256 | + public function save(EntityInterface $entity) { |
|
257 | 257 | return $this->getRecord($entity)->save($entity); |
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
261 | 261 | * @param Closure $logger |
262 | 262 | */ |
263 | - public function setLogger (Closure $logger) { |
|
263 | + public function setLogger(Closure $logger) { |
|
264 | 264 | $this->logger = $logger; |
265 | 265 | } |
266 | 266 | } |
267 | 267 | \ No newline at end of file |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param string $name |
31 | 31 | * @param string[] $columns |
32 | 32 | */ |
33 | - public function __construct (DB $db, $name, array $columns) { |
|
33 | + public function __construct(DB $db, $name, array $columns) { |
|
34 | 34 | parent::__construct($db); |
35 | 35 | $this->name = $name; |
36 | 36 | foreach ($columns as $column) { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return string |
45 | 45 | */ |
46 | - final public function __toString (): string { |
|
46 | + final public function __toString(): string { |
|
47 | 47 | return $this->name; |
48 | 48 | } |
49 | 49 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param array $values |
54 | 54 | * @return int Rows affected. |
55 | 55 | */ |
56 | - public function apply (array $values): int { |
|
56 | + public function apply(array $values): int { |
|
57 | 57 | $columns = implode(',', array_keys($values)); |
58 | 58 | $values = implode(',', $this->db->quote($values)); |
59 | 59 | switch ($this->db->getDriver()) { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param array $match |
73 | 73 | * @return int Rows affected. |
74 | 74 | */ |
75 | - public function delete (array $match): int { |
|
75 | + public function delete(array $match): int { |
|
76 | 76 | $match = SQL::all($this->db->match($match)); |
77 | 77 | return $this->db->exec("DELETE FROM {$this} WHERE {$match}"); |
78 | 78 | } |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * @return Column[] |
82 | 82 | */ |
83 | - final public function getColumns (): array { |
|
83 | + final public function getColumns(): array { |
|
84 | 84 | return $this->columns; |
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
88 | 88 | * @return string |
89 | 89 | */ |
90 | - final public function getName (): string { |
|
90 | + final public function getName(): string { |
|
91 | 91 | return $this->name; |
92 | 92 | } |
93 | 93 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param array $values |
98 | 98 | * @return int Insertion ID. |
99 | 99 | */ |
100 | - public function insert (array $values): int { |
|
100 | + public function insert(array $values): int { |
|
101 | 101 | $columns = implode(',', array_keys($values)); |
102 | 102 | $values = implode(',', $this->db->quote($values)); |
103 | 103 | $this->db->exec("INSERT INTO {$this} ($columns) VALUES ($values)"); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param string $name |
109 | 109 | * @return bool |
110 | 110 | */ |
111 | - public function offsetExists ($name): bool { |
|
111 | + public function offsetExists($name): bool { |
|
112 | 112 | return isset($this->columns[$name]); |
113 | 113 | } |
114 | 114 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param string $name |
117 | 117 | * @return Column |
118 | 118 | */ |
119 | - public function offsetGet ($name): Column { |
|
119 | + public function offsetGet($name): Column { |
|
120 | 120 | return $this->columns[$name]; |
121 | 121 | } |
122 | 122 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string[] $columns Defaults to all columns. |
127 | 127 | * @return Select |
128 | 128 | */ |
129 | - public function select (array $columns = []): Select { |
|
129 | + public function select(array $columns = []): Select { |
|
130 | 130 | if (!$columns) { |
131 | 131 | $columns = $this->columns; |
132 | 132 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param string $name |
140 | 140 | * @return Table |
141 | 141 | */ |
142 | - public function setName (string $name) { |
|
142 | + public function setName(string $name) { |
|
143 | 143 | $clone = clone $this; |
144 | 144 | $clone->name = $name; |
145 | 145 | foreach ($this->columns as $name => $column) { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param array $match |
158 | 158 | * @return int Rows affected. |
159 | 159 | */ |
160 | - public function update (array $values, array $match): int { |
|
160 | + public function update(array $values, array $match): int { |
|
161 | 161 | $values = implode(', ', SQL::isEqual($this->db->quote($values))); |
162 | 162 | $match = SQL::all($this->db->match($match)); |
163 | 163 | return $this->db->exec("UPDATE {$this} SET {$values} WHERE {$match}"); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param string|Select $table |
76 | 76 | * @param array $columns Strings or {@link Column}. Keys are used for aliasing. |
77 | 77 | */ |
78 | - public function __construct (DB $db, $table, array $columns) { |
|
78 | + public function __construct(DB $db, $table, array $columns) { |
|
79 | 79 | parent::__construct($db); |
80 | 80 | if ($table instanceof Select) { |
81 | 81 | $table = $table->toSubquery(); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | /** |
92 | 92 | * Gives the clone a new alias. |
93 | 93 | */ |
94 | - public function __clone () { |
|
94 | + public function __clone() { |
|
95 | 95 | $this->alias = uniqid('_') . "__{$this->table}"; |
96 | 96 | } |
97 | 97 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @param array $args |
100 | 100 | * @return PDOStatement |
101 | 101 | */ |
102 | - public function __invoke (array $args = []) { |
|
102 | + public function __invoke(array $args = []) { |
|
103 | 103 | return $this->execute($args); |
104 | 104 | } |
105 | 105 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return string |
110 | 110 | */ |
111 | - public function __toString (): string { |
|
111 | + public function __toString(): string { |
|
112 | 112 | return $this->alias; |
113 | 113 | } |
114 | 114 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @param array $args Execution arguments. |
119 | 119 | * @return int |
120 | 120 | */ |
121 | - public function count (array $args = []): int { |
|
121 | + public function count(array $args = []): int { |
|
122 | 122 | $clone = clone $this; |
123 | 123 | $clone->setColumns(['COUNT(*)']); |
124 | 124 | return (int)$clone->execute($args)->fetchColumn(); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @param array $args |
131 | 131 | * @return PDOStatement |
132 | 132 | */ |
133 | - public function execute (array $args = []): PDOStatement { |
|
133 | + public function execute(array $args = []): PDOStatement { |
|
134 | 134 | $statement = $this->prepare(); |
135 | 135 | $statement->execute($args); |
136 | 136 | return $statement; |
@@ -144,21 +144,21 @@ discard block |
||
144 | 144 | * @param array $args Execution arguments. |
145 | 145 | * @return array |
146 | 146 | */ |
147 | - public function fetchAll (array $args = []): array { |
|
147 | + public function fetchAll(array $args = []): array { |
|
148 | 148 | return $this->fetcher->__invoke($this->execute($args)); |
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
152 | 152 | * @return string |
153 | 153 | */ |
154 | - final public function getAlias (): string { |
|
154 | + final public function getAlias(): string { |
|
155 | 155 | return $this->alias; |
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
159 | 159 | * @return Closure |
160 | 160 | */ |
161 | - public function getFetcher (): Closure { |
|
161 | + public function getFetcher(): Closure { |
|
162 | 162 | return $this->fetcher; |
163 | 163 | } |
164 | 164 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @return ArrayIterator |
171 | 171 | */ |
172 | - public function getIterator () { |
|
172 | + public function getIterator() { |
|
173 | 173 | return new ArrayIterator($this->fetchAll()); |
174 | 174 | } |
175 | 175 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param string $column |
180 | 180 | * @return $this |
181 | 181 | */ |
182 | - public function group ($column) { |
|
182 | + public function group($column) { |
|
183 | 183 | $this->_group[] = $column; |
184 | 184 | return $this; |
185 | 185 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @param string $condition |
191 | 191 | * @return $this |
192 | 192 | */ |
193 | - public function having ($condition) { |
|
193 | + public function having($condition) { |
|
194 | 194 | $this->_having[] = $condition; |
195 | 195 | return $this; |
196 | 196 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param string $type |
204 | 204 | * @return $this |
205 | 205 | */ |
206 | - public function join ($table, $condition, $type = 'INNER') { |
|
206 | + public function join($table, $condition, $type = 'INNER') { |
|
207 | 207 | if ($table instanceof Select) { |
208 | 208 | $table = $table->toSubquery(); |
209 | 209 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param int $offset |
219 | 219 | * @return $this |
220 | 220 | */ |
221 | - public function limit ($limit, $offset = 0) { |
|
221 | + public function limit($limit, $offset = 0) { |
|
222 | 222 | $this->_limit = " LIMIT {$limit}"; |
223 | 223 | if ($offset) { |
224 | 224 | $this->_limit .= " OFFSET {$offset}"; |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @param string $name Name or alias if used. |
233 | 233 | * @return bool |
234 | 234 | */ |
235 | - public function offsetExists ($name): bool { |
|
235 | + public function offsetExists($name): bool { |
|
236 | 236 | return isset($this->columns[$name]); |
237 | 237 | } |
238 | 238 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @param string $name Name or alias if used. |
243 | 243 | * @return Column |
244 | 244 | */ |
245 | - public function offsetGet ($name): Column { |
|
245 | + public function offsetGet($name): Column { |
|
246 | 246 | return new Column($this->db, $name, $this->alias); |
247 | 247 | } |
248 | 248 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @param string $order |
253 | 253 | * @return $this |
254 | 254 | */ |
255 | - public function order ($order) { |
|
255 | + public function order($order) { |
|
256 | 256 | $this->_order = " ORDER BY {$order}"; |
257 | 257 | return $this; |
258 | 258 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | /** |
261 | 261 | * @return PDOStatement |
262 | 262 | */ |
263 | - public function prepare (): PDOStatement { |
|
263 | + public function prepare(): PDOStatement { |
|
264 | 264 | return $this->db->prepare($this->toSql()); |
265 | 265 | } |
266 | 266 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param array $columns Strings or {@link Column}. Keys are used for aliasing. |
271 | 271 | * @return $this |
272 | 272 | */ |
273 | - public function setColumns (array $columns) { |
|
273 | + public function setColumns(array $columns) { |
|
274 | 274 | $this->columns = []; |
275 | 275 | foreach ($columns as $alias => $column) { |
276 | 276 | if ($column instanceof Column) { |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * @param Closure $fetcher |
295 | 295 | * @return $this |
296 | 296 | */ |
297 | - public function setFetcher (Closure $fetcher) { |
|
297 | + public function setFetcher(Closure $fetcher) { |
|
298 | 298 | $this->fetcher = $fetcher; |
299 | 299 | return $this; |
300 | 300 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | /** |
303 | 303 | * @return string |
304 | 304 | */ |
305 | - public function toSql (): string { |
|
305 | + public function toSql(): string { |
|
306 | 306 | $columns = []; |
307 | 307 | foreach ($this->columns as $alias => $column) { |
308 | 308 | if ($alias !== $column) { |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @return string |
338 | 338 | */ |
339 | - public function toSubquery (): string { |
|
339 | + public function toSubquery(): string { |
|
340 | 340 | return "({$this->toSql()}) AS {$this->getAlias()}"; |
341 | 341 | } |
342 | 342 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * @param string $condition |
347 | 347 | * @return $this |
348 | 348 | */ |
349 | - public function where ($condition) { |
|
349 | + public function where($condition) { |
|
350 | 350 | $this->_where[] = $condition; |
351 | 351 | return $this; |
352 | 352 | } |
@@ -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)) |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @param string[] $conditions |
18 | 18 | * @return string |
19 | 19 | */ |
20 | - public static function all (array $conditions): string { |
|
20 | + public static function all(array $conditions): string { |
|
21 | 21 | if (count($conditions) === 1) { |
22 | 22 | return reset($conditions); |
23 | 23 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param string[] $conditions |
31 | 31 | * @return string |
32 | 32 | */ |
33 | - public static function any (array $conditions): string { |
|
33 | + public static function any(array $conditions): string { |
|
34 | 34 | if (count($conditions) === 1) { |
35 | 35 | return reset($conditions); |
36 | 36 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param string $listOperator |
70 | 70 | * @return string|array |
71 | 71 | */ |
72 | - public static function compare ($a, $operator, $b = null, $subqueryOperator = null, $listOperator = null) { |
|
72 | + public static function compare($a, $operator, $b = null, $subqueryOperator = null, $listOperator = null) { |
|
73 | 73 | if (is_array($a)) { |
74 | 74 | $cmp = []; |
75 | 75 | foreach ($a as $k => $v) { |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string|array|Select $b |
94 | 94 | * @return string|array |
95 | 95 | */ |
96 | - public static function isEqual ($a, $b = null) { |
|
96 | + public static function isEqual($a, $b = null) { |
|
97 | 97 | return static::compare($a, '=', $b, 'ANY', 'IN'); |
98 | 98 | } |
99 | 99 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param string|Select $b |
105 | 105 | * @return string|array |
106 | 106 | */ |
107 | - public static function isGreater ($a, $b = null) { |
|
107 | + public static function isGreater($a, $b = null) { |
|
108 | 108 | return static::compare($a, '>', $b, 'ALL'); |
109 | 109 | } |
110 | 110 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param string|Select $b |
116 | 116 | * @return string|array |
117 | 117 | */ |
118 | - public static function isGreaterOrEqual ($a, $b = null) { |
|
118 | + public static function isGreaterOrEqual($a, $b = null) { |
|
119 | 119 | return static::compare($a, '>=', $b, 'ALL'); |
120 | 120 | } |
121 | 121 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string|Select $b |
127 | 127 | * @return string|array |
128 | 128 | */ |
129 | - public static function isLess ($a, $b = null) { |
|
129 | + public static function isLess($a, $b = null) { |
|
130 | 130 | return static::compare($a, '<', $b, 'ALL'); |
131 | 131 | } |
132 | 132 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param string|Select $b |
138 | 138 | * @return string|array |
139 | 139 | */ |
140 | - public static function isLessOrEqual ($a, $b = null) { |
|
140 | + public static function isLessOrEqual($a, $b = null) { |
|
141 | 141 | return static::compare($a, '<=', $b, 'ALL'); |
142 | 142 | } |
143 | 143 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param string $pattern |
149 | 149 | * @return string|array |
150 | 150 | */ |
151 | - public static function isLike ($x, string $pattern = null) { |
|
151 | + public static function isLike($x, string $pattern = null) { |
|
152 | 152 | return static::compare($x, 'LIKE', $pattern); |
153 | 153 | } |
154 | 154 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param null|bool $identity |
160 | 160 | * @return string|array |
161 | 161 | */ |
162 | - public static function isNot ($x, $identity) { |
|
162 | + public static function isNot($x, $identity) { |
|
163 | 163 | return static::compare($x, 'IS NOT', ['' => 'UNKNOWN', 1 => 'TRUE', 0 => 'FALSE'][$identity]); |
164 | 164 | } |
165 | 165 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param string|array|Select $b |
171 | 171 | * @return string|array |
172 | 172 | */ |
173 | - public static function isNotEqual ($a, $b = null) { |
|
173 | + public static function isNotEqual($a, $b = null) { |
|
174 | 174 | return static::compare($a, '<>', $b, 'ALL', 'NOT IN'); |
175 | 175 | } |
176 | 176 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @param string $pattern |
182 | 182 | * @return string|array |
183 | 183 | */ |
184 | - public static function isNotLike ($x, string $pattern = null) { |
|
184 | + public static function isNotLike($x, string $pattern = null) { |
|
185 | 185 | return static::compare($x, 'NOT LIKE', $pattern); |
186 | 186 | } |
187 | 187 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param string|array $x |
192 | 192 | * @return string|array |
193 | 193 | */ |
194 | - public static function isNotNull ($x) { |
|
194 | + public static function isNotNull($x) { |
|
195 | 195 | if (is_array($x)) { |
196 | 196 | return array_map(__METHOD__, $x); |
197 | 197 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @param string $pattern |
206 | 206 | * @return string|array |
207 | 207 | */ |
208 | - public static function isNotRegExp ($x, string $pattern = null) { |
|
208 | + public static function isNotRegExp($x, string $pattern = null) { |
|
209 | 209 | return static::compare($x, 'NOT REGEXP', $pattern); |
210 | 210 | } |
211 | 211 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * @param string $pattern |
217 | 217 | * @return string|array |
218 | 218 | */ |
219 | - public static function isRegExp ($x, string $pattern = null) { |
|
219 | + public static function isRegExp($x, string $pattern = null) { |
|
220 | 220 | return static::compare($x, 'REGEXP', $pattern); |
221 | 221 | } |
222 | 222 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @param int|array|Countable $count |
227 | 227 | * @return string[] |
228 | 228 | */ |
229 | - public static function marks ($count): array { |
|
229 | + public static function marks($count): array { |
|
230 | 230 | if (is_array($count) or $count instanceof Countable) { |
231 | 231 | $count = count($count); |
232 | 232 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @param string|array $x |
240 | 240 | * @return string|array |
241 | 241 | */ |
242 | - public static function not ($x) { |
|
242 | + public static function not($x) { |
|
243 | 243 | if (is_array($x)) { |
244 | 244 | return array_map(__METHOD__, $x); |
245 | 245 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @param string[] $columns |
255 | 255 | * @return string[] `[column => :column]` |
256 | 256 | */ |
257 | - public static function slots (array $columns): array { |
|
257 | + public static function slots(array $columns): array { |
|
258 | 258 | $slots = []; |
259 | 259 | foreach ($columns as $column) { |
260 | 260 | $slots[(string)$column] = ':' . str_replace('.', '__', $column); |
@@ -262,6 +262,6 @@ discard block |
||
262 | 262 | return $slots; |
263 | 263 | } |
264 | 264 | |
265 | - final private function __construct () { } |
|
265 | + final private function __construct() { } |
|
266 | 266 | |
267 | 267 | } |
268 | 268 | \ No newline at end of file |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param DB $db |
32 | 32 | * @param string $interface |
33 | 33 | */ |
34 | - public function __construct (DB $db, string $interface) { |
|
34 | + public function __construct(DB $db, string $interface) { |
|
35 | 35 | $this->interface = $interface; |
36 | 36 | try { |
37 | 37 | $interface = new ReflectionClass($interface); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param EntityInterface $entity |
58 | 58 | * @return int |
59 | 59 | */ |
60 | - public function count (EntityInterface $entity): int { |
|
60 | + public function count(EntityInterface $entity): int { |
|
61 | 61 | $key = $this->getKey($entity); |
62 | 62 | $count = $this->cache("count.{$key}", function() use ($key) { |
63 | 63 | return $this->select(['COUNT(*)'])->where("{$key}=:id")->prepare(); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param string $class |
76 | 76 | * @return Select |
77 | 77 | */ |
78 | - public function getCollection (EntityInterface $owner, string $class): Select { |
|
78 | + public function getCollection(EntityInterface $owner, string $class): Select { |
|
79 | 79 | $record = $this->db->getRecord($class); |
80 | 80 | $select = $record->select(); |
81 | 81 | $select->join($this, $this[$class]->isEqual($record['id'])); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * @return string |
88 | 88 | */ |
89 | - final public function getInterface (): string { |
|
89 | + final public function getInterface(): string { |
|
90 | 90 | return $this->interface; |
91 | 91 | } |
92 | 92 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param EntityInterface|string $class |
97 | 97 | * @return string |
98 | 98 | */ |
99 | - public function getKey ($class): string { |
|
99 | + public function getKey($class): string { |
|
100 | 100 | if (is_object($class)) { |
101 | 101 | $class = get_class($class); |
102 | 102 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param EntityInterface[] $entities |
115 | 115 | * @return int Rows affected. |
116 | 116 | */ |
117 | - public function link (array $entities): int { |
|
117 | + public function link(array $entities): int { |
|
118 | 118 | $apply = []; |
119 | 119 | foreach ($entities as $entity) { |
120 | 120 | $apply[$this->getKey($entity)] = $entity->getId(); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param string $name |
129 | 129 | * @return bool |
130 | 130 | */ |
131 | - public function offsetExists ($name): bool { |
|
131 | + public function offsetExists($name): bool { |
|
132 | 132 | return isset($this->columns[$name]) or isset($this->columns[$this->keys[$name]]); |
133 | 133 | } |
134 | 134 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @param string $name |
139 | 139 | * @return Column |
140 | 140 | */ |
141 | - public function offsetGet ($name): Column { |
|
141 | + public function offsetGet($name): Column { |
|
142 | 142 | return $this->columns[$name] ?? $this->columns[$this->keys[$name]]; |
143 | 143 | } |
144 | 144 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @param EntityInterface[] $entities |
152 | 152 | * @return int Rows affected. |
153 | 153 | */ |
154 | - public function unlink (array $entities): int { |
|
154 | + public function unlink(array $entities): int { |
|
155 | 155 | $match = []; |
156 | 156 | foreach ($entities as $entity) { |
157 | 157 | $match[$this->getKey($entity)] = $entity->getId(); |
@@ -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 |