Passed
Pull Request — main (#55)
by Thierry
05:38
created
src/Model/Traits/HasProperty.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,8 +36,7 @@
 block discarded – undo
36 36
      */
37 37
     public function saveProperties(array $content)
38 38
     {
39
-        $this->property ? $this->property->update(['content' => $content]) :
40
-            $this->property()->create(['content' => $content]);
39
+        $this->property ? $this->property->update(['content' => $content]) : $this->property()->create(['content' => $content]);
41 40
         // Refresh the relation;
42 41
         $this->load('property');
43 42
     }
Please login to merge, or discard this patch.
src/Service/Report/SessionService.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function getDisbursedAmounts(Collection $chargeIds, Collection $sessionIds): Collection
113 113
     {
114
-        if($chargeIds->count() === 0)
114
+        if ($chargeIds->count() === 0)
115 115
         {
116 116
             return collect();
117 117
         }
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
 
226 226
         $charges = $this->tenantService->tontine()->charges()->active()->get();
227 227
         $disbursements = $this->getDisbursedAmounts($charges->pluck('id'), $sessionIds);
228
-        if($member !== null)
228
+        if ($member !== null)
229 229
         {
230 230
             // The disbursement part of each member id calculated by dividing each amount
231 231
             // by the number of members.
232 232
             $memberCount = $this->memberService->countActiveMembers();
233
-            foreach($disbursements as $disbursement)
233
+            foreach ($disbursements as $disbursement)
234 234
             {
235 235
                 $disbursement->total_amount /= $memberCount;
236 236
             }
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
             ->groupBy('debts.type')
259 259
             ->pluck('total_amount', 'type');
260 260
 
261
-        return (object)[
261
+        return (object) [
262 262
             'principal' => $loan[Debt::TYPE_PRINCIPAL] ?? 0,
263 263
             'interest' => $loan[Debt::TYPE_INTEREST] ?? 0,
264 264
         ];
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
             ->groupBy('debts.type')
284 284
             ->pluck('total_amount', 'type');
285 285
 
286
-        return (object)[
286
+        return (object) [
287 287
             'principal' => ($refund[Debt::TYPE_PRINCIPAL] ?? 0) +
288 288
                 ($partialRefund[Debt::TYPE_PRINCIPAL] ?? 0),
289 289
             'interest' => ($refund[Debt::TYPE_INTEREST] ?? 0) +
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
             ->select(DB::raw('sum(amount) as total_amount'), DB::raw('count(id) as total_count'))
303 303
             ->where('session_id', $session->id)
304 304
             ->first();
305
-        if(!$saving->total_amount)
305
+        if (!$saving->total_amount)
306 306
         {
307 307
             $saving->total_amount = 0;
308 308
         }
309
-        if(!$saving->total_count)
309
+        if (!$saving->total_count)
310 310
         {
311 311
             $saving->total_count = 0;
312 312
         }
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
             ->select(DB::raw('sum(amount) as total_amount'), DB::raw('count(id) as total_count'))
326 326
             ->where('session_id', $session->id)
327 327
             ->first();
328
-        if(!$disbursement->total_amount)
328
+        if (!$disbursement->total_amount)
329 329
         {
330 330
             $disbursement->total_amount = 0;
331 331
         }
332
-        if(!$disbursement->total_count)
332
+        if (!$disbursement->total_count)
333 333
         {
334 334
             $disbursement->total_count = 0;
335 335
         }
Please login to merge, or discard this patch.
src/Service/Meeting/Saving/SavingService.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -155,8 +155,7 @@
 block discarded – undo
155 155
         if($fund !== null)
156 156
         {
157 157
             $saving->fund()->associate($fund);
158
-        }
159
-        else
158
+        } else
160 159
         {
161 160
             $saving->fund()->dissociate();
162 161
         }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -14 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @return Builder|Relation
38 38
      */
39
-    private function getSavingQuery(Session $session, int $fundId): Builder|Relation
39
+    private function getSavingQuery(Session $session, int $fundId): Builder | Relation
40 40
     {
41 41
         // $fundId < 0 => all the savings
42 42
         // $fundId === 0 => savings of the default fund
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         $saving->amount = $amount;
141 141
         $saving->member()->associate($member);
142 142
         $saving->session()->associate($session);
143
-        if($fund !== null)
143
+        if ($fund !== null)
144 144
         {
145 145
             $saving->fund()->associate($fund);
146 146
         }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function createSaving(Session $session, array $values): void
163 163
     {
164
-        if(!($member = $this->getMember($values['member'])))
164
+        if (!($member = $this->getMember($values['member'])))
165 165
         {
166 166
             throw new MessageException(trans('tontine.member.errors.not_found'));
167 167
         }
@@ -182,12 +182,12 @@  discard block
 block discarded – undo
182 182
      */
183 183
     public function updateSaving(Session $session, int $savingId, array $values): void
184 184
     {
185
-        if(!($member = $this->getMember($values['member'])))
185
+        if (!($member = $this->getMember($values['member'])))
186 186
         {
187 187
             throw new MessageException(trans('tontine.member.errors.not_found'));
188 188
         }
189 189
         $saving = $session->savings()->find($savingId);
190
-        if(!$saving)
190
+        if (!$saving)
191 191
         {
192 192
             throw new MessageException(trans('meeting.saving.errors.not_found'));
193 193
         }
@@ -208,13 +208,13 @@  discard block
 block discarded – undo
208 208
      */
209 209
     public function saveSaving(Session $session, int $fundId, int $memberId, int $amount): void
210 210
     {
211
-        if(!($member = $this->getMember($memberId)))
211
+        if (!($member = $this->getMember($memberId)))
212 212
         {
213 213
             throw new MessageException(trans('tontine.member.errors.not_found'));
214 214
         }
215 215
         $fund = !$fundId ? null : $this->fundService->getFund($fundId);
216 216
         $saving = $this->findSaving($session, !$fund ? 0 : $fund->id, $member->id);
217
-        if(!$saving)
217
+        if (!$saving)
218 218
         {
219 219
             $saving = new Saving();
220 220
         }
@@ -234,8 +234,7 @@  discard block
 block discarded – undo
234 234
     public function deleteSaving(Session $session, int $savingId, int $memberId = 0): void
235 235
     {
236 236
         $savingId > 0 ?
237
-            $session->savings()->where('id', $savingId)->delete() :
238
-            $session->savings()->where('member_id', $memberId)->delete();
237
+            $session->savings()->where('id', $savingId)->delete() : $session->savings()->where('member_id', $memberId)->delete();
239 238
     }
240 239
 
241 240
     /**
@@ -252,8 +251,7 @@  discard block
 block discarded – undo
252 251
             $query->where('session_id', $session->id)
253 252
                 ->where(function(Builder $query) use($fundId) {
254 253
                     $fundId > 0 ?
255
-                        $query->where('fund_id', $fundId) :
256
-                        $query->whereNull('fund_id');
254
+                        $query->where('fund_id', $fundId) : $query->whereNull('fund_id');
257 255
                 });
258 256
         };
259 257
     }
@@ -267,7 +265,7 @@  discard block
 block discarded – undo
267 265
      * @return Builder|Relation
268 266
      */
269 267
     private function getMembersQuery(Session $session, int $fundId,
270
-        string $search, ?bool $filter): Builder|Relation
268
+        string $search, ?bool $filter): Builder | Relation
271 269
     {
272 270
         $savingsFilter = $this->getMemberSavingsFilter($session, $fundId);
273 271
         return $this->tenantService->tontine()->members()->active()
@@ -391,10 +389,10 @@  discard block
 block discarded – undo
391 389
     {
392 390
         $tontine = $this->tenantService->tontine();
393 391
         $properties = $tontine->properties;
394
-        if(isset($properties['closings'][$session->id][$fundId]))
392
+        if (isset($properties['closings'][$session->id][$fundId]))
395 393
         {
396 394
             unset($properties['closings'][$session->id][$fundId]);
397
-            if(count($properties['closings'][$session->id]) == 0)
395
+            if (count($properties['closings'][$session->id]) == 0)
398 396
             {
399 397
                 unset($properties['closings'][$session->id]);
400 398
             }
Please login to merge, or discard this patch.
src/Service/Meeting/Credit/LoanService.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -228,8 +228,7 @@
 block discarded – undo
228 228
         if($fund !== null)
229 229
         {
230 230
             $loan->fund()->associate($fund);
231
-        }
232
-        else
231
+        } else
233 232
         {
234 233
             $loan->fund()->dissociate();
235 234
         }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         $loan->interest_rate = $values['interest_rate'];
139 139
         $loan->member()->associate($member);
140 140
         $loan->session()->associate($session);
141
-        if($fund !== null)
141
+        if ($fund !== null)
142 142
         {
143 143
             $loan->fund()->associate($fund);
144 144
         }
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
             $principal = $values['principal'];
149 149
             $interest = $values['interest'];
150 150
             // Create an entry for each type of debt
151
-            if($principal > 0)
151
+            if ($principal > 0)
152 152
             {
153 153
                 $loan->debts()->create(['type' => Debt::TYPE_PRINCIPAL, 'amount' => $principal]);
154 154
             }
155
-            if($interest > 0)
155
+            if ($interest > 0)
156 156
             {
157 157
                 $loan->debts()->create(['type' => Debt::TYPE_INTEREST, 'amount' => $interest]);
158 158
             }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
         $loan->interest_type = $values['interest_type'];
176 176
         $loan->interest_rate = $values['interest_rate'];
177 177
         $loan->member()->associate($member);
178
-        if($fund !== null)
178
+        if ($fund !== null)
179 179
         {
180 180
             $loan->fund()->associate($fund);
181 181
         }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
             $interest = $values['interest'];
191 191
             $loan->debts()->principal()->update(['amount' => $principal]);
192 192
             // The interest debt may need to be created or deleted.
193
-            if($interest <= 0)
193
+            if ($interest <= 0)
194 194
             {
195 195
                 $loan->debts()->where('type', Debt::TYPE_INTEREST)->delete();
196 196
                 return;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public function deleteLoan(Session $session, int $loanId): void
211 211
     {
212
-        if(($loan = $session->loans()->find($loanId)) !== null)
212
+        if (($loan = $session->loans()->find($loanId)) !== null)
213 213
         {
214 214
             DB::transaction(function() use($loan) {
215 215
                 $loan->refunds()->delete();
Please login to merge, or discard this patch.
src/Validation/Meeting/LoanValidator.php 1 patch
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
             'fund_id' => 'required|integer|min:0',
33 33
         ]);
34 34
         $validator->after(function($validator) use($values) {
35
-            if((float)$values['principal'] <= 0)
35
+            if ((float) $values['principal'] <= 0)
36 36
             {
37 37
                 $validator->errors()->add('principal', trans('validation.gt.numeric', [
38 38
                     'attribute' => trans('meeting.loan.labels.principal'),
@@ -40,19 +40,18 @@  discard block
 block discarded – undo
40 40
                 ]));
41 41
             }
42 42
         });
43
-        if($validator->fails())
43
+        if ($validator->fails())
44 44
         {
45 45
             throw new ValidationException($validator);
46 46
         }
47 47
 
48 48
         $validated = $validator->validated();
49
-        $validated['principal'] = $this->localeService->convertMoneyToInt((float)$validated['principal']);
49
+        $validated['principal'] = $this->localeService->convertMoneyToInt((float) $validated['principal']);
50 50
         // Interest rates must be saved as int, so the value is multiplied by 100.
51 51
         $validated['interest_rate'] = $validated['interest_type'] === 'f' ?
52
-            0 : (int)(100 * $validated['interest']);
52
+            0 : (int) (100 * $validated['interest']);
53 53
         $validated['interest'] = $validated['interest_type'] === 'f' ?
54
-            $this->localeService->convertMoneyToInt((float)$validated['interest']) :
55
-            (int)($validated['principal'] * $validated['interest'] / 100);
54
+            $this->localeService->convertMoneyToInt((float) $validated['interest']) : (int) ($validated['principal'] * $validated['interest'] / 100);
56 55
 
57 56
         return $validated;
58 57
     }
Please login to merge, or discard this patch.
src/Validation/Meeting/ClosingValidator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,13 +32,13 @@
 block discarded – undo
32 32
         $validator = Validator::make($this->values($values), [
33 33
             'amount' => 'required|regex:/^\d+(\.\d{1,2})?$/',
34 34
         ]);
35
-        if($validator->fails())
35
+        if ($validator->fails())
36 36
         {
37 37
             throw new ValidationException($validator);
38 38
         }
39 39
 
40 40
         $validated = $validator->validated();
41
-        $validated['amount'] = $this->localeService->convertMoneyToInt((float)$validated['amount']);
41
+        $validated['amount'] = $this->localeService->convertMoneyToInt((float) $validated['amount']);
42 42
         return $validated;
43 43
     }
44 44
 }
Please login to merge, or discard this patch.
app/Ajax/Web/Tontine/Fund.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             'title' => trans('common.actions.cancel'),
59 59
             'class' => 'btn btn-tertiary',
60 60
             'click' => 'close',
61
-        ],[
61
+        ], [
62 62
             'title' => trans('common.actions.save'),
63 63
             'class' => 'btn btn-primary',
64 64
             'click' => $this->rq()->create(pm()->form('fund-form')),
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
             'title' => trans('common.actions.cancel'),
90 90
             'class' => 'btn btn-tertiary',
91 91
             'click' => 'close',
92
-        ],[
92
+        ], [
93 93
             'title' => trans('common.actions.save'),
94 94
             'class' => 'btn btn-primary',
95 95
             'click' => $this->rq()->update($fund->id, pm()->form('fund-form')),
Please login to merge, or discard this patch.
app/Ajax/Web/Tontine/Category.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             'title' => trans('common.actions.cancel'),
65 65
             'class' => 'btn btn-tertiary',
66 66
             'click' => 'close',
67
-        ],[
67
+        ], [
68 68
             'title' => trans('common.actions.save'),
69 69
             'class' => 'btn btn-primary',
70 70
             'click' => $this->rq()->create(pm()->form('category-form')),
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             'title' => trans('common.actions.cancel'),
102 102
             'class' => 'btn btn-tertiary',
103 103
             'click' => 'close',
104
-        ],[
104
+        ], [
105 105
             'title' => trans('common.actions.save'),
106 106
             'class' => 'btn btn-primary',
107 107
             'click' => $this->rq()->update($category->id, pm()->form('category-form')),
Please login to merge, or discard this patch.
app/Ajax/Web/Meeting/Saving/Closing.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 
80 80
     public function editClosing(int $fundId)
81 81
     {
82
-        if($this->session->closed)
82
+        if ($this->session->closed)
83 83
         {
84 84
             $this->notify->warning(trans('meeting.warnings.session.closed'));
85 85
             return $this->response;
86 86
         }
87 87
         $funds = $this->fundService->getFundList();
88
-        if(!isset($funds[$fundId]))
88
+        if (!isset($funds[$fundId]))
89 89
         {
90 90
             return $this->response;
91 91
         }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     public function saveClosing(int $fundId, array $formValues)
116 116
     {
117 117
         $funds = $this->fundService->getFundList();
118
-        if(!isset($funds[$fundId]))
118
+        if (!isset($funds[$fundId]))
119 119
         {
120 120
             return $this->response;
121 121
         }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     public function deleteClosing(int $fundId)
133 133
     {
134 134
         $funds = $this->fundService->getFundList();
135
-        if(!isset($funds[$fundId]))
135
+        if (!isset($funds[$fundId]))
136 136
         {
137 137
             return $this->response;
138 138
         }
Please login to merge, or discard this patch.