Passed
Branch main (ec7022)
by Razi
10:41
created
phpunit.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 include __DIR__.'/vendor/autoload.php';
4 4
 
5 5
 $capsule = new \Illuminate\Database\Capsule\Manager;
6
-$capsule->addConnection([ 'driver' => 'sqlite', 'database' => ':memory:', 'prefix' => 'prfx_' ]);
6
+$capsule->addConnection(['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => 'prfx_']);
7 7
 $capsule->setEventDispatcher(new \Illuminate\Events\Dispatcher);
8 8
 $capsule->bootEloquent();
9 9
 $capsule->setAsGlobal();
Please login to merge, or discard this patch.
src/Traits/CascadedSoftDeletes.php 1 patch
Spacing   +16 added lines, -18 removed lines patch added patch discarded remove patch
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
     protected static function bootCascadedSoftDeletes()
25 25
     {
26 26
 
27
-        static::deleted(function ($model) {
27
+        static::deleted(function($model) {
28 28
             $model->deleteCascadedSoftDeletes();
29 29
         });
30 30
 
31 31
         if (static::instanceUsesSoftDelete()) {
32
-            static::restoring(function ($model) {
32
+            static::restoring(function($model) {
33 33
                 static::$instanceDeletedAt = $model->{$model->getDeletedAtColumn()};
34 34
             });
35 35
 
36
-            static::restored(function ($model) {
36
+            static::restored(function($model) {
37 37
                 $model->restoreCascadedSoftDeleted();
38 38
             });
39 39
         }
@@ -44,17 +44,16 @@  discard block
 block discarded – undo
44 44
      */
45 45
     protected function deleteCascadedSoftDeletes() : void
46 46
     {
47
-        if($this->isHardDeleting())
47
+        if ($this->isHardDeleting())
48 48
             return;
49 49
 
50
-        if(config('cascaded-soft-deletes.queue_cascades_by_default') === true) {
50
+        if (config('cascaded-soft-deletes.queue_cascades_by_default') === true) {
51 51
             CascadeSoftDeletes::dispatch($this, 'delete', null)->onQueue(config('cascaded-soft-deletes.queue_name'));
52 52
         }
53 53
         else {
54 54
             // @codeCoverageIgnoreStart
55 55
             Str::startsWith(app()->version(), "7") ? 
56
-                CascadeSoftDeletes::dispatchNow($this, 'delete', null) : 
57
-                CascadeSoftDeletes::dispatchSync($this, 'delete', null); 
56
+                CascadeSoftDeletes::dispatchNow($this, 'delete', null) : CascadeSoftDeletes::dispatchSync($this, 'delete', null); 
58 57
             // @codeCoverageIgnoreEnd
59 58
         }
60 59
 
@@ -65,14 +64,13 @@  discard block
 block discarded – undo
65 64
      */
66 65
     protected function restoreCascadedSoftDeleted() : void
67 66
     {
68
-        if(config('cascaded-soft-deletes.queue_cascades_by_default') === true) {
67
+        if (config('cascaded-soft-deletes.queue_cascades_by_default') === true) {
69 68
             CascadeSoftDeletes::dispatch($this, 'restore', static::$instanceDeletedAt)->onQueue(config('cascaded-soft-deletes.queue_name'));
70 69
         }
71 70
         else {
72 71
             // @codeCoverageIgnoreStart
73 72
             Str::startsWith(app()->version(), "7") ? 
74
-                CascadeSoftDeletes::dispatchNow($this, 'restore', static::$instanceDeletedAt) :
75
-                CascadeSoftDeletes::dispatchSync($this, 'restore', static::$instanceDeletedAt);
73
+                CascadeSoftDeletes::dispatchNow($this, 'restore', static::$instanceDeletedAt) : CascadeSoftDeletes::dispatchSync($this, 'restore', static::$instanceDeletedAt);
76 74
             // @codeCoverageIgnoreEnd
77 75
         }
78 76
         // CascadeSoftDeletes::dispatch($this, 'restore', static::$instanceDeletedAt);
@@ -85,9 +83,9 @@  discard block
 block discarded – undo
85 83
      */
86 84
     public function cascadeSoftDeletes(string $action, ?\Carbon\Carbon $instanceDeletedAt = null) : void
87 85
     {
88
-        if(method_exists($this, 'getCascadedSoftDeletes')) {
86
+        if (method_exists($this, 'getCascadedSoftDeletes')) {
89 87
             $relations = collect($this->getCascadedSoftDeletes());
90
-        } else if(property_exists($this, 'cascadedSoftDeletes')) {
88
+        } else if (property_exists($this, 'cascadedSoftDeletes')) {
91 89
             $relations = collect($this->cascadedSoftDeletes);
92 90
         } else {
93 91
             throw new RuntimeException('neither getCascadedSoftDeletes function or cascaded_soft_deletes property exists!');
@@ -96,18 +94,18 @@  discard block
 block discarded – undo
96 94
         $relations->each(function($item, $key) use ($action, $instanceDeletedAt) {
97 95
 
98 96
             $relation = $key;
99
-            if(is_numeric($key))
97
+            if (is_numeric($key))
100 98
                 $relation = $item;
101 99
 
102
-            if(!is_callable($item) && !$this->relationUsesSoftDelete($relation))
100
+            if (!is_callable($item) && !$this->relationUsesSoftDelete($relation))
103 101
                 throw new LogicException('relationship '.$relation.' does not use SoftDeletes trait.');
104 102
 
105
-            if(is_callable($item))
103
+            if (is_callable($item))
106 104
                 $query = $item();
107 105
             else
108 106
                 $query = $this->{$relation}();
109 107
 
110
-            if($action == 'delete')
108
+            if ($action == 'delete')
111 109
                 $query->get()->each->delete();
112 110
             else
113 111
                 $query
@@ -137,7 +135,7 @@  discard block
 block discarded – undo
137 135
      */
138 136
     protected function isHardDeleting() : bool
139 137
     {
140
-        return ! $this->instanceUsesSoftDelete() || $this->forceDeleting;
138
+        return !$this->instanceUsesSoftDelete() || $this->forceDeleting;
141 139
     }
142 140
 
143 141
     /**
@@ -167,7 +165,7 @@  discard block
 block discarded – undo
167 165
     {
168 166
         static $softDeletes;
169 167
 
170
-        if(is_null($softDeletes))
168
+        if (is_null($softDeletes))
171 169
             $softDeletes = collect([]);
172 170
 
173 171
         return $softDeletes->get($relation, function() use($relation, $softDeletes) {
Please login to merge, or discard this patch.