@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param string $passwd |
54 | 54 | * @param array $options |
55 | 55 | */ |
56 | - public function __construct ($dsn, $username = null, $passwd = null, $options = null) { |
|
56 | + public function __construct($dsn, $username = null, $passwd = null, $options = null) { |
|
57 | 57 | parent::__construct($dsn, $username, $passwd, $options); |
58 | 58 | $this->driver = $this->getAttribute(self::ATTR_DRIVER_NAME); |
59 | 59 | $this->setAttribute(self::ATTR_DEFAULT_FETCH_MODE, self::FETCH_ASSOC); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param string $sql |
76 | 76 | * @return int |
77 | 77 | */ |
78 | - public function exec ($sql): int { |
|
78 | + public function exec($sql): int { |
|
79 | 79 | $this->logger->__invoke($sql); |
80 | 80 | return parent::exec($sql); |
81 | 81 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @return string |
85 | 85 | */ |
86 | - final public function getDriver (): string { |
|
86 | + final public function getDriver(): string { |
|
87 | 87 | return $this->driver; |
88 | 88 | } |
89 | 89 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $interface |
94 | 94 | * @return Junction |
95 | 95 | */ |
96 | - public function getJunction ($interface) { |
|
96 | + public function getJunction($interface) { |
|
97 | 97 | if (!isset($this->junctions[$interface])) { |
98 | 98 | $this->junctions[$interface] = Junction::fromInterface($this, $interface); |
99 | 99 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | /** |
104 | 104 | * @return Closure |
105 | 105 | */ |
106 | - public function getLogger () { |
|
106 | + public function getLogger() { |
|
107 | 107 | return $this->logger; |
108 | 108 | } |
109 | 109 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param string|EntityInterface $class |
114 | 114 | * @return Record |
115 | 115 | */ |
116 | - public function getRecord ($class) { |
|
116 | + public function getRecord($class) { |
|
117 | 117 | $name = $class; |
118 | 118 | if (is_object($name)) { |
119 | 119 | $name = get_class($name); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @param mixed $b |
139 | 139 | * @return string |
140 | 140 | */ |
141 | - public function match ($a, $b) { |
|
141 | + public function match($a, $b) { |
|
142 | 142 | if ($b instanceof Closure) { |
143 | 143 | if (!$a instanceof Column) { |
144 | 144 | $a = new Column($this, $a); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @param array $match |
165 | 165 | * @return string[] |
166 | 166 | */ |
167 | - public function matchArray (array $match) { |
|
167 | + public function matchArray(array $match) { |
|
168 | 168 | return array_map([$this, 'match'], array_keys($match), $match); |
169 | 169 | } |
170 | 170 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @param string $class Class or interface name. |
173 | 173 | * @return bool |
174 | 174 | */ |
175 | - public function offsetExists ($class): bool { |
|
175 | + public function offsetExists($class): bool { |
|
176 | 176 | return (bool)$this->offsetGet($class); |
177 | 177 | } |
178 | 178 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param string $class Class or interface name. |
181 | 181 | * @return null|Record|Junction |
182 | 182 | */ |
183 | - public function offsetGet ($class) { |
|
183 | + public function offsetGet($class) { |
|
184 | 184 | if (class_exists($class)) { |
185 | 185 | return $this->getRecord($class); |
186 | 186 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param string $class Class or interface name. |
195 | 195 | * @param Record|Junction $access |
196 | 196 | */ |
197 | - public function offsetSet ($class, $access) { |
|
197 | + public function offsetSet($class, $access) { |
|
198 | 198 | if ($access instanceof Record) { |
199 | 199 | $this->setRecord($class, $access); |
200 | 200 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | /** |
208 | 208 | * @param string $class Class or interface name. |
209 | 209 | */ |
210 | - public function offsetUnset ($class) { |
|
210 | + public function offsetUnset($class) { |
|
211 | 211 | unset($this->records[$class]); |
212 | 212 | unset($this->junctions[$class]); |
213 | 213 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @param array $options |
220 | 220 | * @return Statement |
221 | 221 | */ |
222 | - public function prepare ($sql, $options = []) { |
|
222 | + public function prepare($sql, $options = []) { |
|
223 | 223 | $this->logger->__invoke($sql); |
224 | 224 | /** @var Statement $statement */ |
225 | 225 | $statement = parent::prepare($sql, $options); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @param array $ctorargs |
236 | 236 | * @return Statement |
237 | 237 | */ |
238 | - public function query ($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) { |
|
238 | + public function query($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) { |
|
239 | 239 | $this->logger->__invoke($sql); |
240 | 240 | /** @var Statement $statement */ |
241 | 241 | $statement = parent::query(...func_get_args()); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @param int $type Ignored. |
255 | 255 | * @return string |
256 | 256 | */ |
257 | - public function quote ($value, $type = null) { |
|
257 | + public function quote($value, $type = null) { |
|
258 | 258 | if ($value instanceof ExpressionInterface) { |
259 | 259 | return (string)$value; |
260 | 260 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @param array $values |
275 | 275 | * @return string[] |
276 | 276 | */ |
277 | - public function quoteArray (array $values): array { |
|
277 | + public function quoteArray(array $values): array { |
|
278 | 278 | return array_map([$this, 'quote'], $values); |
279 | 279 | } |
280 | 280 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @param mixed $value |
285 | 285 | * @return string|string[] |
286 | 286 | */ |
287 | - public function quoteMixed ($value) { |
|
287 | + public function quoteMixed($value) { |
|
288 | 288 | if (is_array($value)) { |
289 | 289 | return $this->quoteArray($value); |
290 | 290 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @param EntityInterface $entity |
298 | 298 | * @return int ID |
299 | 299 | */ |
300 | - public function save (EntityInterface $entity): int { |
|
300 | + public function save(EntityInterface $entity): int { |
|
301 | 301 | return $this->getRecord($entity)->save($entity); |
302 | 302 | } |
303 | 303 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @param Junction $junction |
307 | 307 | * @return $this |
308 | 308 | */ |
309 | - public function setJunction (string $interface, Junction $junction) { |
|
309 | + public function setJunction(string $interface, Junction $junction) { |
|
310 | 310 | $this->junctions[$interface] = $junction; |
311 | 311 | return $this; |
312 | 312 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @param Closure $logger |
316 | 316 | * @return $this |
317 | 317 | */ |
318 | - public function setLogger (Closure $logger) { |
|
318 | + public function setLogger(Closure $logger) { |
|
319 | 319 | $this->logger = $logger; |
320 | 320 | return $this; |
321 | 321 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | * @param Record $record |
326 | 326 | * @return $this |
327 | 327 | */ |
328 | - public function setRecord (string $class, Record $record) { |
|
328 | + public function setRecord(string $class, Record $record) { |
|
329 | 329 | $this->records[$class] = $record; |
330 | 330 | return $this; |
331 | 331 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param string $interface |
30 | 30 | * @return Junction |
31 | 31 | */ |
32 | - public static function fromInterface (DB $db, string $interface) { |
|
32 | + public static function fromInterface(DB $db, string $interface) { |
|
33 | 33 | try { |
34 | 34 | $ref = new ReflectionClass($interface); |
35 | 35 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string $table |
53 | 53 | * @param string[] $classes |
54 | 54 | */ |
55 | - public function __construct (DB $db, string $table, array $classes) { |
|
55 | + public function __construct(DB $db, string $table, array $classes) { |
|
56 | 56 | parent::__construct($db, $table, array_keys($classes)); |
57 | 57 | $this->classes = $classes; |
58 | 58 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param array $match |
67 | 67 | * @return Select |
68 | 68 | */ |
69 | - public function getCollection (string $key, array $match = []) { |
|
69 | + public function getCollection(string $key, array $match = []) { |
|
70 | 70 | $record = $this->db->getRecord($this->classes[$key]); |
71 | 71 | $select = $record->select(); |
72 | 72 | $select->join($this, $this[$key]->isEqual($record['id'])); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param int[] $ids Keyed by column. |
83 | 83 | * @return int Rows affected. |
84 | 84 | */ |
85 | - public function link (array $ids): int { |
|
85 | + public function link(array $ids): int { |
|
86 | 86 | $link = $this->cache(__FUNCTION__, function() { |
87 | 87 | $columns = implode(',', array_keys($this->columns)); |
88 | 88 | $slots = implode(',', SQL::slots(array_keys($this->columns))); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param array $values |
24 | 24 | * @return Value |
25 | 25 | */ |
26 | - public function coalesce (array $values) { |
|
26 | + public function coalesce(array $values) { |
|
27 | 27 | array_unshift($values, $this); |
28 | 28 | $values = implode(',', $this->db->quoteArray($values)); |
29 | 29 | return new Value($this->db, "COALESCE({$values})"); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param string[] $values `[when => then]` |
36 | 36 | * @return Choice |
37 | 37 | */ |
38 | - public function getChoice (array $values) { |
|
38 | + public function getChoice(array $values) { |
|
39 | 39 | return new Choice($this->db, "{$this}", $values); |
40 | 40 | } |
41 | 41 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param null|bool|string|Select $arg |
49 | 49 | * @return Predicate |
50 | 50 | */ |
51 | - public function is ($arg): Predicate { |
|
51 | + public function is($arg): Predicate { |
|
52 | 52 | if ($arg === null or is_bool($arg)) { |
53 | 53 | $arg = ['' => 'NULL', 1 => 'TRUE', 0 => 'FALSE'][$arg]; |
54 | 54 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param number|string $max |
67 | 67 | * @return Predicate |
68 | 68 | */ |
69 | - public function isBetween ($min, $max) { |
|
69 | + public function isBetween($min, $max) { |
|
70 | 70 | return new Predicate("{$this} BETWEEN {$this->db->quote($min)} AND {$this->db->quote($max)}"); |
71 | 71 | } |
72 | 72 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param string|array|Select $arg |
77 | 77 | * @return Predicate |
78 | 78 | */ |
79 | - public function isEqual ($arg) { |
|
79 | + public function isEqual($arg) { |
|
80 | 80 | return Predicate::compare($this, $this->db->quoteMixed($arg)); |
81 | 81 | } |
82 | 82 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param string|Select $arg |
87 | 87 | * @return Predicate |
88 | 88 | */ |
89 | - public function isGreater ($arg) { |
|
89 | + public function isGreater($arg) { |
|
90 | 90 | return Predicate::compare($this, $this->db->quote($arg), '>', 'ALL'); |
91 | 91 | } |
92 | 92 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param string|Select $arg |
97 | 97 | * @return Predicate |
98 | 98 | */ |
99 | - public function isGreaterOrEqual ($arg) { |
|
99 | + public function isGreaterOrEqual($arg) { |
|
100 | 100 | return Predicate::compare($this, $this->db->quote($arg), '>=', 'ALL'); |
101 | 101 | } |
102 | 102 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param string|Select $arg |
107 | 107 | * @return Predicate |
108 | 108 | */ |
109 | - public function isLess ($arg) { |
|
109 | + public function isLess($arg) { |
|
110 | 110 | return Predicate::compare($this, $this->db->quote($arg), '<', 'ALL'); |
111 | 111 | } |
112 | 112 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param string|Select $arg |
117 | 117 | * @return Predicate |
118 | 118 | */ |
119 | - public function isLessOrEqual ($arg) { |
|
119 | + public function isLessOrEqual($arg) { |
|
120 | 120 | return Predicate::compare($this, $this->db->quote($arg), '<=', 'ALL'); |
121 | 121 | } |
122 | 122 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string $pattern |
127 | 127 | * @return Predicate |
128 | 128 | */ |
129 | - public function isLike (string $pattern) { |
|
129 | + public function isLike(string $pattern) { |
|
130 | 130 | return Predicate::compare($this, $this->db->quote($pattern), 'LIKE'); |
131 | 131 | } |
132 | 132 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param null|bool|string|Select $arg |
137 | 137 | * @return Predicate |
138 | 138 | */ |
139 | - public function isNot ($arg) { |
|
139 | + public function isNot($arg) { |
|
140 | 140 | return $this->is($arg)->invert(); |
141 | 141 | } |
142 | 142 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param number|string $max |
148 | 148 | * @return Predicate |
149 | 149 | */ |
150 | - public function isNotBetween ($min, $max) { |
|
150 | + public function isNotBetween($min, $max) { |
|
151 | 151 | return new Predicate("{$this} NOT BETWEEN {$this->db->quote($min)} AND {$this->db->quote($max)}"); |
152 | 152 | } |
153 | 153 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param string|array|Select $arg |
158 | 158 | * @return Predicate |
159 | 159 | */ |
160 | - public function isNotEqual ($arg) { |
|
160 | + public function isNotEqual($arg) { |
|
161 | 161 | return Predicate::compare($this, $this->db->quoteMixed($arg), '<>', 'ALL', 'NOT IN'); |
162 | 162 | } |
163 | 163 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param string $pattern |
168 | 168 | * @return Predicate |
169 | 169 | */ |
170 | - public function isNotLike (string $pattern) { |
|
170 | + public function isNotLike(string $pattern) { |
|
171 | 171 | return Predicate::compare($this, $this->db->quote($pattern), 'NOT LIKE'); |
172 | 172 | } |
173 | 173 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param string $pattern |
178 | 178 | * @return Predicate |
179 | 179 | */ |
180 | - public function isNotRegExp (string $pattern) { |
|
180 | + public function isNotRegExp(string $pattern) { |
|
181 | 181 | return Predicate::compare($this, $this->db->quote($pattern), 'NOT REGEXP'); |
182 | 182 | } |
183 | 183 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param string $pattern |
188 | 188 | * @return Predicate |
189 | 189 | */ |
190 | - public function isRegExp (string $pattern) { |
|
190 | + public function isRegExp(string $pattern) { |
|
191 | 191 | return Predicate::compare($this, $this->db->quote($pattern), 'REGEXP'); |
192 | 192 | } |
193 | 193 | } |
194 | 194 | \ No newline at end of file |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string $subject |
53 | 53 | * @param array $values `[when => then]` for the subject. |
54 | 54 | */ |
55 | - public function __construct (DB $db, string $subject = null, array $values = []) { |
|
55 | + public function __construct(DB $db, string $subject = null, array $values = []) { |
|
56 | 56 | parent::__construct($db, ''); |
57 | 57 | $this->subject = $subject; |
58 | 58 | $this->setValues($values); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * @return string |
63 | 63 | */ |
64 | - public function __toString () { |
|
64 | + public function __toString() { |
|
65 | 65 | $sql = 'CASE'; |
66 | 66 | if (isset($this->subject)) { |
67 | 67 | $sql .= " {$this->subject}"; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param string|ValueInterface $else |
81 | 81 | * @return $this |
82 | 82 | */ |
83 | - public function setElse ($else) { |
|
83 | + public function setElse($else) { |
|
84 | 84 | $this->else = isset($else) ? $this->db->quote($else) : null; |
85 | 85 | return $this; |
86 | 86 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param string|ValueInterface $then |
93 | 93 | * @return $this |
94 | 94 | */ |
95 | - public function setValue ($when, $then) { |
|
95 | + public function setValue($when, $then) { |
|
96 | 96 | $this->values[$this->db->quote($when)] = $this->db->quote($then); |
97 | 97 | return $this; |
98 | 98 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param array $values `[when => then]` |
104 | 104 | * @return $this |
105 | 105 | */ |
106 | - public function setValues (array $values) { |
|
106 | + public function setValues(array $values) { |
|
107 | 107 | foreach ($values as $when => $then) { |
108 | 108 | $this->setValue($when, $then); |
109 | 109 | } |