@@ -10,5 +10,5 @@ |
||
10 | 10 | /** |
11 | 11 | * @return int |
12 | 12 | */ |
13 | - public function getId (); |
|
13 | + public function getId(); |
|
14 | 14 | } |
15 | 15 | \ No newline at end of file |
@@ -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 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param array $args |
32 | 32 | * @return $this |
33 | 33 | */ |
34 | - public function __invoke (array $args = null) { |
|
34 | + public function __invoke(array $args = null) { |
|
35 | 35 | $this->execute($args); |
36 | 36 | return $this; |
37 | 37 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return string |
43 | 43 | */ |
44 | - public function __toString () { |
|
44 | + public function __toString() { |
|
45 | 45 | return $this->queryString; |
46 | 46 | } |
47 | 47 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @return bool |
55 | 55 | * @throws ArgumentCountError |
56 | 56 | */ |
57 | - public function execute ($args = null) { |
|
57 | + public function execute($args = null) { |
|
58 | 58 | $this->db->getLogger()->__invoke($this->queryString); |
59 | 59 | if ($result = !parent::execute($args)) { |
60 | 60 | $info = $this->errorInfo(); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return int |
73 | 73 | */ |
74 | - public function getId (): int { |
|
74 | + public function getId(): int { |
|
75 | 75 | return (int)$this->db->lastInsertId(); |
76 | 76 | } |
77 | 77 | } |
@@ -10,5 +10,5 @@ |
||
10 | 10 | /** |
11 | 11 | * @return string |
12 | 12 | */ |
13 | - public function __toString (); |
|
13 | + public function __toString(); |
|
14 | 14 | } |
15 | 15 | \ No newline at end of file |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @return array |
32 | 32 | */ |
33 | - public function getAttributes (): array { |
|
33 | + public function getAttributes(): array { |
|
34 | 34 | return $this->attributes ?? []; |
35 | 35 | } |
36 | 36 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param mixed $attr |
39 | 39 | * @return bool |
40 | 40 | */ |
41 | - public function offsetExists ($attr): bool { |
|
41 | + public function offsetExists($attr): bool { |
|
42 | 42 | return isset($this->attributes) and array_key_exists($attr, $this->attributes); |
43 | 43 | } |
44 | 44 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param mixed $attr |
47 | 47 | * @return null|mixed |
48 | 48 | */ |
49 | - public function offsetGet ($attr) { |
|
49 | + public function offsetGet($attr) { |
|
50 | 50 | return $this->attributes[$attr] ?? null; |
51 | 51 | } |
52 | 52 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param mixed $attr |
55 | 55 | * @param mixed $value |
56 | 56 | */ |
57 | - public function offsetSet ($attr, $value): void { |
|
57 | + public function offsetSet($attr, $value): void { |
|
58 | 58 | if (isset($attr)) { |
59 | 59 | $this->attributes[$attr] = $value; |
60 | 60 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * @param mixed $attr |
68 | 68 | */ |
69 | - public function offsetUnset ($attr): void { |
|
69 | + public function offsetUnset($attr): void { |
|
70 | 70 | unset($this->attributes[$attr]); |
71 | 71 | } |
72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param array $attributes |
75 | 75 | * @return $this |
76 | 76 | */ |
77 | - public function setAttributes (array $attributes) { |
|
77 | + public function setAttributes(array $attributes) { |
|
78 | 78 | $this->attributes = $attributes; |
79 | 79 | return $this; |
80 | 80 | } |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | * @param int|array|Countable $count |
19 | 19 | * @return ExpressionInterface[] |
20 | 20 | */ |
21 | - public static function marks ($count): array { |
|
21 | + public static function marks($count): array { |
|
22 | 22 | static $mark; |
23 | 23 | $mark ??= new class implements ExpressionInterface { |
24 | 24 | |
25 | - public function __toString () { |
|
25 | + public function __toString() { |
|
26 | 26 | return '?'; |
27 | 27 | } |
28 | 28 | }; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param string[] $columns |
42 | 42 | * @return string[] `["column" => ":column"]` |
43 | 43 | */ |
44 | - public static function slots (array $columns): array { |
|
44 | + public static function slots(array $columns): array { |
|
45 | 45 | $slots = []; |
46 | 46 | foreach ($columns as $column) { |
47 | 47 | $slots[$column] = ':' . str_replace('.', '__', $column); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param string[] $columns |
54 | 54 | * @return string[] `["column" => "column=:column"]` |
55 | 55 | */ |
56 | - public static function slotsEqual (array $columns): array { |
|
56 | + public static function slotsEqual(array $columns): array { |
|
57 | 57 | $slots = static::slots($columns); |
58 | 58 | foreach ($slots as $column => $slot) { |
59 | 59 | $slots[$column] = "{$column} = {$slot}"; |
@@ -61,6 +61,6 @@ discard block |
||
61 | 61 | return $slots; |
62 | 62 | } |
63 | 63 | |
64 | - final private function __construct () { |
|
64 | + final private function __construct() { |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | \ No newline at end of file |
@@ -12,7 +12,7 @@ |
||
12 | 12 | * |
13 | 13 | * @return static |
14 | 14 | */ |
15 | - public function not () { |
|
15 | + public function not() { |
|
16 | 16 | return static::factory($this->db, "NOT({$this})"); |
17 | 17 | } |
18 | 18 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param DB $db |
29 | 29 | * @param string $expression |
30 | 30 | */ |
31 | - public function __construct (DB $db, string $expression) { |
|
31 | + public function __construct(DB $db, string $expression) { |
|
32 | 32 | $this->db = $db; |
33 | 33 | $this->expression = $expression; |
34 | 34 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * @return string |
38 | 38 | */ |
39 | - public function __toString () { |
|
39 | + public function __toString() { |
|
40 | 40 | return $this->expression; |
41 | 41 | } |
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -17,7 +17,7 @@ |
||
17 | 17 | * @param array $args The first argument must be a {@link DB} instance. |
18 | 18 | * @return static |
19 | 19 | */ |
20 | - public static function __callStatic (string $ignored, array $args) { |
|
20 | + public static function __callStatic(string $ignored, array $args) { |
|
21 | 21 | /** @var DB $db */ |
22 | 22 | $db = $args[0]; |
23 | 23 | unset($args[0]); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @param DB $db |
16 | 16 | * @param string $name |
17 | 17 | */ |
18 | - public function __construct (DB $db, string $name) { |
|
18 | + public function __construct(DB $db, string $name) { |
|
19 | 19 | parent::__construct($db, $name, ['entity', 'attribute', 'value']); |
20 | 20 | } |
21 | 21 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param string $attribute |
27 | 27 | * @return bool |
28 | 28 | */ |
29 | - public function exists (int $id, string $attribute): bool { |
|
29 | + public function exists(int $id, string $attribute): bool { |
|
30 | 30 | $statement = $this->cache(__FUNCTION__, function() { |
31 | 31 | return $this->select(['COUNT(*) > 0'])->where('entity = ? AND attribute = ?')->prepare(); |
32 | 32 | }); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param array $match `[attribute => value]`. If empty, selects all IDs for entities having at least one attribute. |
45 | 45 | * @return Select |
46 | 46 | */ |
47 | - public function find (array $match) { |
|
47 | + public function find(array $match) { |
|
48 | 48 | $select = $this->select([$this['entity']]); |
49 | 49 | $prior = $this; |
50 | 50 | foreach ($match as $attribute => $value) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param int $id |
67 | 67 | * @return array `[attribute => value]` |
68 | 68 | */ |
69 | - public function load (int $id): array { |
|
69 | + public function load(int $id): array { |
|
70 | 70 | $statement = $this->cache(__FUNCTION__, function() { |
71 | 71 | $select = $this->select(['attribute', 'value']); |
72 | 72 | $select->where('entity = ?'); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param int[] $ids |
83 | 83 | * @return array[] `[id => attribute => value] |
84 | 84 | */ |
85 | - public function loadAll (array $ids): array { |
|
85 | + public function loadAll(array $ids): array { |
|
86 | 86 | if (empty($ids)) { |
87 | 87 | return []; |
88 | 88 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @param array $values `[attribute => value]` |
108 | 108 | * @return $this |
109 | 109 | */ |
110 | - public function save (int $id, array $values) { |
|
110 | + public function save(int $id, array $values) { |
|
111 | 111 | $this->delete([ |
112 | 112 | $this['entity']->isEqual($id), |
113 | 113 | $this['attribute']->isNotEqual(array_keys($values)) |