Passed
Pull Request — main (#39)
by
unknown
12:33
created
src/Model.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -93,20 +93,20 @@  discard block
 block discarded – undo
93 93
             $parts = preg_split('/(?=[A-Z])/', $key, -1, PREG_SPLIT_NO_EMPTY);
94 94
             if (strtolower($parts[0]) == 'own') {
95 95
                 if (strtolower($parts[2]) == 'list') {
96
-                    return Managers::recordManager()->find(strtolower($parts[1]))->where($this->getName() . '_id = "' . $this->_id . '"')->get();
96
+                    return Managers::recordManager()->find(strtolower($parts[1]))->where($this->getName().'_id = "'.$this->_id.'"')->get();
97 97
                 }
98 98
             }
99 99
             if (strtolower($parts[0]) == 'shared') {
100 100
                 if (strtolower($parts[2]) == 'list') {
101
-                    $rel_table = Managers::tableManager()->tableExists($this->table . '_' . strtolower($parts[1])) ? $this->table . '_' . strtolower($parts[1]) : strtolower($parts[1]) . '_' . $this->table;
102
-                    $relations = Managers::recordManager()->find($rel_table)->where($this->getName() . '_id = "' . $this->_id . '"')->get();
101
+                    $rel_table = Managers::tableManager()->tableExists($this->table.'_'.strtolower($parts[1])) ? $this->table.'_'.strtolower($parts[1]) : strtolower($parts[1]).'_'.$this->table;
102
+                    $relations = Managers::recordManager()->find($rel_table)->where($this->getName().'_id = "'.$this->_id.'"')->get();
103 103
                     $rel_ids = '';
104 104
                     foreach ($relations as $relation) {
105
-                        $key = strtolower($parts[1]) . '_id';
106
-                        $rel_ids .= "'" . $relation->$key . "',";
105
+                        $key = strtolower($parts[1]).'_id';
106
+                        $rel_ids .= "'".$relation->$key."',";
107 107
                     }
108 108
                     $rel_ids = substr($rel_ids, 0, -1);
109
-                    return Managers::recordManager()->find(strtolower($parts[1]))->where('id IN (' . $rel_ids . ')')->get();
109
+                    return Managers::recordManager()->find(strtolower($parts[1]))->where('id IN ('.$rel_ids.')')->get();
110 110
                 }
111 111
             }
112 112
         }
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
             return $this->properties[$key];
116 116
         }
117 117
 
118
-        if (array_key_exists($key . '_id', $this->properties)) {
119
-            return Managers::recordManager()->getById(Managers::modelManager()->create($key), $this->properties[$key . '_id']);
118
+        if (array_key_exists($key.'_id', $this->properties)) {
119
+            return Managers::recordManager()->getById(Managers::modelManager()->create($key), $this->properties[$key.'_id']);
120 120
         }
121 121
 
122 122
         throw new Exception\KeyNotFoundException();
Please login to merge, or discard this patch.
src/Database.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     private bool $useUUID = false;
38 38
 
39
-    public function __construct(Connection $connection , bool $useUUID = false)
39
+    public function __construct(Connection $connection, bool $useUUID = false)
40 40
     {
41 41
         $this->connection = $connection;
42 42
         $this->platform = $this->connection->getDatabasePlatform();
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 
50 50
     public function registerEvents()
51 51
     {
52
-        Event::subscribeTo('model.save', function ($model) {
52
+        Event::subscribeTo('model.save', function($model) {
53 53
             return $this->save($model);
54 54
         });
55
-        Event::subscribeTo('model.delete', function ($model) {
55
+        Event::subscribeTo('model.delete', function($model) {
56 56
             return $this->delete($model);
57 57
         });
58 58
     }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      * @param array $params
66 66
      * @return integer
67 67
      */
68
-    public function exec(string $sql, array $params=array()): int
68
+    public function exec(string $sql, array $params = array()): int
69 69
     {
70 70
         return  $this->connection->executeStatement($sql, $params);
71 71
     }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      * @param array $params
78 78
      * @return array
79 79
      */
80
-    public function getAll(string $sql, array $params=[]): array
80
+    public function getAll(string $sql, array $params = []): array
81 81
     {
82 82
         return  $this->connection->executeQuery($sql, $params)->fetchAllAssociative();
83 83
     }
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
     /**
260 260
      * Get collection of all records from table
261 261
      */
262
-    public function get(String $table,mixed $id = null) : Model|Collection
262
+    public function get(String $table, mixed $id = null) : Model | Collection
263 263
     {
264 264
         // For backward compatibility reason
265
-        if($id != null){
266
-            return $this->getOne($table,$id);
265
+        if ($id != null) {
266
+            return $this->getOne($table, $id);
267 267
         }
268 268
 
269 269
         return Managers::recordManager()->getAll($table);
Please login to merge, or discard this patch.
src/Manager/ModelManager.php 1 patch
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,6 @@
 block discarded – undo
10 10
 class ModelManager {
11 11
     /**
12 12
      * Creates and return models
13
-
14 13
      */
15 14
     function create(string $name): Model
16 15
     {
Please login to merge, or discard this patch.
src/Manager/RecordManager.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -67,15 +67,15 @@
 block discarded – undo
67 67
     }
68 68
 
69 69
     /**
70
-    * Get single record by id
71
-    *
72
-    */
70
+     * Get single record by id
71
+     *
72
+     */
73 73
     public function getById(Model $model, mixed $id): Model
74 74
     {
75 75
         $query =  (new QueryBuilder($this->connection))
76
-                 ->select('*')
77
-                 ->from($model->getName(), 't')
78
-                 ->where("t.id = '".$id."'");
76
+                    ->select('*')
77
+                    ->from($model->getName(), 't')
78
+                    ->where("t.id = '".$id."'");
79 79
         $result = $this->connection->executeQuery($query)->fetchAssociative();
80 80
         $result = $result ? $result : [];
81 81
         return $model->setProperties($result)->setLoaded();
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
     */
73 73
     public function getById(Model $model, mixed $id): Model
74 74
     {
75
-        $query =  (new QueryBuilder($this->connection))
75
+        $query = (new QueryBuilder($this->connection))
76 76
                  ->select('*')
77 77
                  ->from($model->getName(), 't')
78 78
                  ->where("t.id = '".$id."'");
Please login to merge, or discard this patch.
src/Manager/TableManager.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
     {
69 69
         $table = new Table($model->getName());
70 70
         if ($this->isUsingUUID) {
71
-            $table->addColumn('id', 'string', ['length' => 36, 'notnull' => true,]);
71
+            $table->addColumn('id', 'string', ['length' => 36, 'notnull' => true, ]);
72 72
         } else {
73 73
             $table->addColumn("id", "integer", array("unsigned" => true, "autoincrement" => true));
74 74
         }
Please login to merge, or discard this patch.
src/QueryBuilder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 class QueryBuilder extends \Doctrine\DBAL\Query\QueryBuilder
9 9
 {
10 10
     private string $table;
11
-    private array $relations= [];
11
+    private array $relations = [];
12 12
 
13 13
     public function __construct(\Doctrine\DBAL\Connection $connection)
14 14
     {
Please login to merge, or discard this patch.
src/Managers.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use Scrawler\Arca\Manager\TableManager;
9 9
 
10 10
 
11
-class Managers{
11
+class Managers {
12 12
     private static TableManager $tableManager;
13 13
     private static RecordManager $recordManager;
14 14
 
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
         
20 20
     }
21 21
 
22
-    public static function create(Connection $connection, bool $isUsingUUID = false){
23
-        self::$tableManager = new TableManager($connection,$isUsingUUID);
24
-        self::$recordManager = new RecordManager($connection,$isUsingUUID);
22
+    public static function create(Connection $connection, bool $isUsingUUID = false) {
23
+        self::$tableManager = new TableManager($connection, $isUsingUUID);
24
+        self::$recordManager = new RecordManager($connection, $isUsingUUID);
25 25
         self::$modelManager = new ModelManager();
26 26
     }
27 27
 
Please login to merge, or discard this patch.
src/Facade/Database.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@  discard block
 block discarded – undo
10 10
 {
11 11
     private static $database;
12 12
 
13
-    public static function connect(array $connectionParams,$isUsingUUID = false)
13
+    public static function connect(array $connectionParams, $isUsingUUID = false)
14 14
     {
15 15
 
16 16
         if (self::$database == null) {
17 17
             $connection = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
18
-            self::$database = new DB($connection,$isUsingUUID);
18
+            self::$database = new DB($connection, $isUsingUUID);
19 19
             return self::$database;
20 20
         }
21 21
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         return self::getDB()->exec($sql);
48 48
     }
49 49
 
50
-    public static function delete($model){
50
+    public static function delete($model) {
51 51
         return self::getDB()->delete($model);
52 52
     }
53 53
 
Please login to merge, or discard this patch.