Passed
Push — main ( a875d8...8fc75d )
by Sammy
02:45 queued 54s
created
src/CruditesExceptionFactory.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
         list($state, $code, $message) = $errorInfo;
56 56
         $functs = [
57 57
             // violation: column cannot be null
58
-            1048 => function ($message) {
58
+            1048 => function($message) {
59 59
                 preg_match("#Column '(.+)' cannot be null#", $message, $m);
60 60
                 return ['FIELD_REQUIRED', $m[1]];
61 61
             },
62 62
 
63
-            1054 => function ($message) {
63
+            1054 => function($message) {
64 64
                 return ['COLUMN_DOES_NOT_EXIST', $message];
65 65
             },
66 66
 
67 67
             // violation: duplicate key
68
-            1062 => function ($message) {
68
+            1062 => function($message) {
69 69
                 if (preg_match("#'([^']+)' for key '([^']+)'#", $message, $m)) {
70 70
                     $entry = $m[1];
71 71
                     $key = $m[2];
@@ -79,25 +79,25 @@  discard block
 block discarded – undo
79 79
                 return ["DUPLICATE_KEY:".$m[1]];
80 80
             },
81 81
 
82
-            1064 => function ($message) {
82
+            1064 => function($message) {
83 83
                 preg_match("#right syntax to use near '(.+)'#", $message, $m);
84 84
                 return ['SYNTAX_ERROR', $m[1]];
85 85
             },
86 86
 
87
-            1146 => function ($message) {
87
+            1146 => function($message) {
88 88
                 return ['TABLE_DOES_NOT_EXIST', $message];
89 89
             },
90 90
 
91
-            1264 => function ($message) {
91
+            1264 => function($message) {
92 92
                 preg_match("#for column '(.+)'#", $message, $m);
93 93
                 return ['VALUE_OUT_OF_RANGE', $m[1]];
94 94
             },
95 95
 
96
-            1364 => function ($message) {
96
+            1364 => function($message) {
97 97
                 return ['FIELD_REQUIRED', $message];
98 98
             },
99 99
 
100
-            1451 => function ($message) {
100
+            1451 => function($message) {
101 101
                 preg_match("#CONSTRAINT `(.+)` FOREIGN#", $message, $m);
102 102
                 return ['RELATIONAL_INTEGRITY', $m[1]];
103 103
             },
@@ -106,6 +106,6 @@  discard block
 block discarded – undo
106 106
         if (isset($functs[$code]))
107 107
             return [call_user_func($functs[$code], $message), $code];
108 108
 
109
-        return ['FUBAR #' . $state . '-' . $code . '-' . $message, $code];
109
+        return ['FUBAR #'.$state.'-'.$code.'-'.$message, $code];
110 110
     }
111 111
 }
Please login to merge, or discard this patch.
src/Errors/CruditesError.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,12 +16,12 @@  discard block
 block discarded – undo
16 16
         $this->message = $message;
17 17
     }
18 18
 
19
-    public function __toString(){
19
+    public function __toString() {
20 20
         $ret = $this->message;
21 21
         
22
-        if(!empty($this->table))
22
+        if (!empty($this->table))
23 23
             $ret .= sprintf(' on table "%s"', $this->table);
24
-        if(!empty($this->columns))
24
+        if (!empty($this->columns))
25 25
             $ret .= sprintf(' on column(s) "%s"', implode('", "', $this->columns));
26 26
 
27 27
         return $ret;
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $errorInfo = null;
33 33
 
34
-        if(method_exists($something_PDO, 'errorInfo'))
34
+        if (method_exists($something_PDO, 'errorInfo'))
35 35
             $errorInfo = $something_PDO->errorInfo();
36
-        elseif(property_exists($something_PDO, 'errorInfo'))
36
+        elseif (property_exists($something_PDO, 'errorInfo'))
37 37
             $errorInfo = $something_PDO->errorInfo;
38 38
         else
39 39
             throw new \InvalidArgumentException('INVALID_PDO_CLASS');
Please login to merge, or discard this patch.
src/Crudites.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $select->selectAlso(['count' => ['COUNT(*)']]);
56 56
         $res = $select->retCol();
57 57
         if (is_array($res)) {
58
-            return (int) current($res);
58
+            return (int)current($res);
59 59
         }
60 60
 
61 61
         return null;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             $res->execute($dat_ass);
97 97
         }
98 98
         
99
-        return $res instanceof \PDOStatement? $res : null;
99
+        return $res instanceof \PDOStatement ? $res : null;
100 100
     }
101 101
 
102 102
     public static function distinctFor(string $table, string $column_name, string $filter_by_value = null)
Please login to merge, or discard this patch.
src/Grammar/AutoJoin.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,13 +119,13 @@
 block discarded – undo
119 119
                     continue; // dont load the log information
120 120
                 } else {
121 121
                     $m = [];
122
-                    if (preg_match('/(.+)_(' . $fk_column->foreignColumnName() . ')$/', $fk_column->name(), $m)) {
122
+                    if (preg_match('/(.+)_('.$fk_column->foreignColumnName().')$/', $fk_column->name(), $m)) {
123 123
                         $foreign_table_alias = $m[1];
124 124
                     } else {
125 125
                         $foreign_table_alias = $foreign_table_name;
126 126
                     }
127 127
 
128
-                    $foreign_table_alias = $single_fk ? $foreign_table_alias : $foreign_table_alias . '_' . $fk_column->name();
128
+                    $foreign_table_alias = $single_fk ? $foreign_table_alias : $foreign_table_alias.'_'.$fk_column->name();
129 129
 
130 130
                     // auto select non nullable columns
131 131
                 }
Please login to merge, or discard this patch.
src/Connection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@
 block discarded – undo
113 113
     private static function options(array $provided = []): array
114 114
     {
115 115
         if (isset($provided[\PDO::ATTR_ERRMODE])) {
116
-            unset($provided[\PDO::ATTR_ERRMODE]);          // the one option you cannot change
116
+            unset($provided[\PDO::ATTR_ERRMODE]); // the one option you cannot change
117 117
         }
118 118
 
119 119
         return array_merge(
Please login to merge, or discard this patch.
src/Result.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
             throw new CruditesException('RUN_OR_PREPARE_QUERY_BEFORE_CALLING_METHOD');
51 51
 
52 52
         if (!method_exists($pdo_statement, $method))
53
-            throw new \BadMethodCallException(__FUNCTION__ . " method $method() does not exist in PDOStatement class");
53
+            throw new \BadMethodCallException(__FUNCTION__." method $method() does not exist in PDOStatement class");
54 54
 
55 55
 
56 56
         return call_user_func_array([$pdo_statement, $method], $args);
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             throw new CruditesException('PDO_PREPARE_STRING');
103 103
             
104 104
         } catch (\PDOException $e) {
105
-            throw new CruditesException('PDO_EXCEPTION: ' . $e->getMessage(), $e->getCode(), $e);
105
+            throw new CruditesException('PDO_EXCEPTION: '.$e->getMessage(), $e->getCode(), $e);
106 106
         }
107 107
 
108 108
         return $this;
Please login to merge, or discard this patch.
src/Table/Row.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 
52 52
     public function __toString()
53 53
     {
54
-        return PHP_EOL . 'load: '
54
+        return PHP_EOL.'load: '
55 55
         . json_encode($this->load)
56
-        . PHP_EOL . 'alterations: '
56
+        . PHP_EOL.'alterations: '
57 57
         . json_encode(array_keys($this->alterations));
58 58
     }
59 59
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
             }
150 150
 
151 151
             // replaces empty strings with null or default value
152
-            if (trim('' . $datass[$field_name]) === '' && $attributes->nullable()) {
152
+            if (trim(''.$datass[$field_name]) === '' && $attributes->nullable()) {
153 153
                 $datass[$field_name] = $attributes->nullable() ? null : $attributes->default();
154 154
             }
155 155
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         
208 208
         $unique_match = $this->schema->matchUniqueness($this->table, $this->load);
209 209
 
210
-        if(empty($unique_match)){
210
+        if (empty($unique_match)) {
211 211
             throw new CruditesException('UNIQUE_MATCH_NOT_FOUND');
212 212
         }
213 213
 
Please login to merge, or discard this patch.
src/Relation/DatabaseRelations.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,24 +27,24 @@  discard block
 block discarded – undo
27 27
     public function listRelations(): array
28 28
     {
29 29
         $relations = [];
30
-        foreach($this->connection->schema()->foreignKeysFor() as $table => $join){
30
+        foreach ($this->connection->schema()->foreignKeysFor() as $table => $join) {
31 31
 
32
-            if(count($join) == 1){
33
-                $res = new HasOne($table, $join,$this->connection);
32
+            if (count($join) == 1) {
33
+                $res = new HasOne($table, $join, $this->connection);
34 34
                 $relations["$res"] = $res;
35 35
             }
36
-            else if(count($join) == 2){
37
-                $res = new OneToMany($table, $join,$this->connection);
36
+            else if (count($join) == 2) {
37
+                $res = new OneToMany($table, $join, $this->connection);
38 38
                 $relations["$res"] = $res;
39 39
 
40
-                $res = new OneToMany($table, array_reverse($join),$this->connection);
40
+                $res = new OneToMany($table, array_reverse($join), $this->connection);
41 41
                 $relations["$res"] = $res;
42 42
             }
43
-            else if(count($join) == 3){
44
-                $res = new OneToManyQualified($table, $join,$this->connection);
43
+            else if (count($join) == 3) {
44
+                $res = new OneToManyQualified($table, $join, $this->connection);
45 45
                 $relations["$res"] = $res;
46 46
 
47
-                $res = new OneToManyQualified($table, array_reverse($join),$this->connection);
47
+                $res = new OneToManyQualified($table, array_reverse($join), $this->connection);
48 48
                 $relations["$res"] = $res;
49 49
             }
50 50
             else
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
     {
67 67
         $ret = [];
68 68
 
69
-        foreach($this->relations as $urn => $relation){
70
-            if($relation->source() === $source){
69
+        foreach ($this->relations as $urn => $relation) {
70
+            if ($relation->source() === $source) {
71 71
                 $ret[$urn] = $relation;
72 72
             }
73 73
         }
Please login to merge, or discard this patch.
src/Relation/AbstractRelation.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     protected $secondary_table;
18 18
     protected $secondary_col;
19 19
 
20
-    public const NAME='ABSTRACT_RELATION';
20
+    public const NAME = 'ABSTRACT_RELATION';
21 21
 
22 22
     
23 23
     public function __debugInfo()
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
         $this->connection = $c;
47 47
     }
48 48
 
49
-    public function source(){
49
+    public function source() {
50 50
         return $this->primary_table;
51 51
     }
52 52
 
53
-    public function target(){
53
+    public function target() {
54 54
         return $this->secondary_table;
55 55
     }
56 56
 
Please login to merge, or discard this patch.