Passed
Pull Request — main (#54)
by Thierry
13:54
created
app/Ajax/Web/Meeting/Pool/Auction.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
      */
101 101
     public function togglePayment(string $auctionId)
102 102
     {
103
-        if($this->session->closed)
103
+        if ($this->session->closed)
104 104
         {
105 105
             $this->notify->warning(trans('meeting.warnings.session.closed'));
106 106
             return $this->response;
Please login to merge, or discard this patch.
app/Ajax/Web/Meeting/Credit/Loan.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function addLoan()
106 106
     {
107
-        if($this->session->closed)
107
+        if ($this->session->closed)
108 108
         {
109 109
             $this->notify->warning(trans('meeting.warnings.session.closed'));
110 110
             return $this->response;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             'title' => trans('common.actions.cancel'),
124 124
             'class' => 'btn btn-tertiary',
125 125
             'click' => 'close',
126
-        ],[
126
+        ], [
127 127
             'title' => trans('common.actions.save'),
128 128
             'class' => 'btn btn-primary',
129 129
             'click' => $this->rq()->createLoan(pm()->form('loan-form')),
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function createLoan(array $formValues)
141 141
     {
142
-        if($this->session->closed)
142
+        if ($this->session->closed)
143 143
         {
144 144
             $this->notify->warning(trans('meeting.warnings.session.closed'));
145 145
             return $this->response;
@@ -163,19 +163,19 @@  discard block
 block discarded – undo
163 163
      */
164 164
     public function editLoan(int $loanId)
165 165
     {
166
-        if($this->session->closed)
166
+        if ($this->session->closed)
167 167
         {
168 168
             $this->notify->warning(trans('meeting.warnings.session.closed'));
169 169
             return $this->response;
170 170
         }
171 171
         $loan = $this->loanService->getSessionLoan($this->session, $loanId);
172
-        if(!$loan)
172
+        if (!$loan)
173 173
         {
174 174
             $this->notify->warning(trans('meeting.loan.errors.not_found'));
175 175
             return $this->response;
176 176
         }
177 177
         // A refunded loan, or that was created from a remitment cannot be updated.
178
-        if($loan->refunds_count > 0 || $loan->remitment_id)
178
+        if ($loan->refunds_count > 0 || $loan->remitment_id)
179 179
         {
180 180
             $this->notify->warning(trans('meeting.loan.errors.update'));
181 181
             return $this->response;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
             'title' => trans('common.actions.cancel'),
192 192
             'class' => 'btn btn-tertiary',
193 193
             'click' => 'close',
194
-        ],[
194
+        ], [
195 195
             'title' => trans('common.actions.save'),
196 196
             'class' => 'btn btn-primary',
197 197
             'click' => $this->rq()->updateLoan($loanId, pm()->form('loan-form')),
@@ -207,19 +207,19 @@  discard block
 block discarded – undo
207 207
      */
208 208
     public function updateLoan(int $loanId, array $formValues)
209 209
     {
210
-        if($this->session->closed)
210
+        if ($this->session->closed)
211 211
         {
212 212
             $this->notify->warning(trans('meeting.warnings.session.closed'));
213 213
             return $this->response;
214 214
         }
215 215
         $loan = $this->loanService->getSessionLoan($this->session, $loanId);
216
-        if(!$loan)
216
+        if (!$loan)
217 217
         {
218 218
             $this->notify->warning(trans('meeting.loan.errors.not_found'));
219 219
             return $this->response;
220 220
         }
221 221
         // A refunded loan, or that was created from a remitment cannot be updated.
222
-        if($loan->refunds_count > 0 || $loan->remitment_id)
222
+        if ($loan->refunds_count > 0 || $loan->remitment_id)
223 223
         {
224 224
             $this->notify->warning(trans('meeting.loan.errors.update'));
225 225
             return $this->response;
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
     public function deleteLoan(int $loanId)
241 241
     {
242
-        if($this->session->closed)
242
+        if ($this->session->closed)
243 243
         {
244 244
             $this->notify->warning(trans('meeting.warnings.session.closed'));
245 245
             return $this->response;
Please login to merge, or discard this patch.
app/Console/Commands/CreateAnnotationsDir.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
     /**
28 28
      * Execute the console command.
29 29
      *
30
-      * @return int
30
+     * @return int
31 31
      */
32 32
     public function handle()
33 33
     {
Please login to merge, or discard this patch.
src/Validation/Planning/SessionValidator.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,18 +46,18 @@  discard block
 block discarded – undo
46 46
             'host_id' => 'integer|min:0',
47 47
         ]);
48 48
         $validator->after(function($validator) use($values) {
49
-            if($this->sessionDateExists($values['date'], $values['id'] ?? 0))
49
+            if ($this->sessionDateExists($values['date'], $values['id'] ?? 0))
50 50
             {
51 51
                 $validator->errors()->add('date', trans('tontine.session.errors.date_dup'));
52 52
             }
53 53
         });
54
-        if($validator->fails())
54
+        if ($validator->fails())
55 55
         {
56 56
             throw new ValidationException($validator);
57 57
         }
58 58
 
59 59
         $validated = $validator->validated();
60
-        if(!$validated['host_id'])
60
+        if (!$validated['host_id'])
61 61
         {
62 62
             $validated['host_id'] = null;
63 63
         }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             'venue' => 'nullable|string',
76 76
             'notes' => 'nullable|string',
77 77
         ]);
78
-        if($validator->fails())
78
+        if ($validator->fails())
79 79
         {
80 80
             throw new ValidationException($validator);
81 81
         }
Please login to merge, or discard this patch.
app/Ajax/Web/Planning/Session.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             'title' => trans('common.actions.cancel'),
97 97
             'class' => 'btn btn-tertiary',
98 98
             'click' => 'close',
99
-        ],[
99
+        ], [
100 100
             'title' => trans('common.actions.save'),
101 101
             'class' => 'btn btn-primary',
102 102
             'click' => $this->rq()->create(pm()->form('session-form')),
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
             'title' => trans('common.actions.cancel'),
128 128
             'class' => 'btn btn-tertiary',
129 129
             'click' => 'close',
130
-        ],[
130
+        ], [
131 131
             'title' => trans('common.actions.year'),
132 132
             'class' => 'btn btn-primary',
133 133
             'click' => $this->rq()->years(),
134
-        ],[
134
+        ], [
135 135
             'title' => trans('common.actions.save'),
136 136
             'class' => 'btn btn-primary',
137 137
             'click' => $this->rq()->createList(pm()->form('session-list')),
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
     private function parseSessionList(string $sessions): array
161 161
     {
162 162
         $sessions = array_map(function($value) {
163
-            if(!($value = trim($value, " \t\n\r;")))
163
+            if (!($value = trim($value, " \t\n\r;")))
164 164
             {
165 165
                 return [];
166 166
             }
167 167
             $values = explode(";", $value);
168
-            if(count($values) !== 2)
168
+            if (count($values) !== 2)
169 169
             {
170 170
                 return []; // Todo: throw an exception
171 171
             }
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
         // Check uniqueness of session dates
184 184
         $sessionDates = array_unique(array_map(fn($session) => $session['date'], $sessions));
185
-        if(count($sessions) !== count($sessionDates))
185
+        if (count($sessions) !== count($sessionDates))
186 186
         {
187 187
             throw new MessageException(trans('tontine.session.errors.date_dup'));
188 188
         }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
             'title' => trans('common.actions.cancel'),
216 216
             'class' => 'btn btn-tertiary',
217 217
             'click' => 'close',
218
-        ],[
218
+        ], [
219 219
             'title' => trans('common.actions.save'),
220 220
             'class' => 'btn btn-primary',
221 221
             'click' => $this->rq()->update($session->id, pm()->form('session-form')),
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
             'title' => trans('common.actions.cancel'),
254 254
             'class' => 'btn btn-tertiary',
255 255
             'click' => 'close',
256
-        ],[
256
+        ], [
257 257
             'title' => trans('common.actions.save'),
258 258
             'class' => 'btn btn-primary',
259 259
             'click' => $this->rq()->saveVenue($session->id, pm()->form('session-form')),
Please login to merge, or discard this patch.
src/Service/Meeting/Saving/ProfitService.php 1 patch
Spacing   +16 added lines, -19 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
         // The closing sessions ids
46 46
         $closingSessionIds = array_keys($this->savingService->getFundClosings($fundId));
47
-        if(count($closingSessionIds) === 0)
47
+        if (count($closingSessionIds) === 0)
48 48
         {
49 49
             // No closing session yet
50 50
             return $sessions;
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         // The previous closing sessions
53 53
         $closingSessions = $sessions->filter(fn($session) =>
54 54
             $session->id !== $currentSession->id && in_array($session->id, $closingSessionIds));
55
-        if($closingSessions->count() === 0)
55
+        if ($closingSessions->count() === 0)
56 56
         {
57 57
             // All the closing sessions are after the current session.
58 58
             return $sessions;
@@ -93,31 +93,31 @@  discard block
 block discarded – undo
93 93
         int $profitAmount): Collection
94 94
     {
95 95
         // Set savings durations and distributions
96
-        foreach($savings as $saving)
96
+        foreach ($savings as $saving)
97 97
         {
98 98
             $saving->duration = $this->getSavingDuration($sessions, $saving);
99 99
             $saving->distribution = $saving->amount * $saving->duration;
100 100
             $saving->profit = 0;
101 101
         }
102 102
         // Reduce the distributions
103
-        $distributionGcd = (int)$savings->reduce(function($gcd, $saving) {
104
-            if($gcd === 0)
103
+        $distributionGcd = (int) $savings->reduce(function($gcd, $saving) {
104
+            if ($gcd === 0)
105 105
             {
106 106
                 return $saving->distribution;
107 107
             }
108
-            if($saving->duration === 0)
108
+            if ($saving->duration === 0)
109 109
             {
110 110
                 return $gcd;
111 111
             }
112 112
             return gmp_gcd($gcd, $saving->distribution);
113 113
         }, $savings->first()->distribution);
114
-        if($distributionGcd > 0)
114
+        if ($distributionGcd > 0)
115 115
         {
116
-            $sum = (int)($savings->sum('distribution') / $distributionGcd);
117
-            foreach($savings as $saving)
116
+            $sum = (int) ($savings->sum('distribution') / $distributionGcd);
117
+            foreach ($savings as $saving)
118 118
             {
119 119
                 $saving->distribution /= $distributionGcd;
120
-                $saving->profit = (int)($profitAmount * $saving->distribution / $sum);
120
+                $saving->profit = (int) ($profitAmount * $saving->distribution / $sum);
121 121
             }
122 122
         }
123 123
 
@@ -145,9 +145,8 @@  discard block
 block discarded – undo
145 145
             ->orderBy('sessions.start_at', 'asc')
146 146
             ->with(['session', 'member']);
147 147
         $savings = $fundId > 0 ?
148
-            $query->where('savings.fund_id', $fundId)->get() :
149
-            $query->whereNull('savings.fund_id')->get();
150
-        if($savings->count() === 0)
148
+            $query->where('savings.fund_id', $fundId)->get() : $query->whereNull('savings.fund_id')->get();
149
+        if ($savings->count() === 0)
151 150
         {
152 151
             return $savings;
153 152
         }
@@ -167,13 +166,13 @@  discard block
 block discarded – undo
167 166
         // The part value makes sense only iwhen there is more than 2 savings
168 167
         // with distribution greater than 0.
169 168
         $savings = $savings->filter(fn($saving) => $saving->distribution > 0);
170
-        if($savings->count() < 2)
169
+        if ($savings->count() < 2)
171 170
         {
172 171
             return 0;
173 172
         }
174 173
 
175 174
         $saving = $savings->first();
176
-        return (int)($saving->amount * $saving->duration / $saving->distribution);
175
+        return (int) ($saving->amount * $saving->duration / $saving->distribution);
177 176
     }
178 177
 
179 178
     /**
@@ -200,8 +199,7 @@  discard block
 block discarded – undo
200 199
             ->select(DB::raw("sum(amount) as total"))
201 200
             ->whereIn('session_id', $sessionIds);
202 201
         $saving = $fundId > 0 ?
203
-            $query->where('savings.fund_id', $fundId)->first() :
204
-            $query->whereNull('savings.fund_id')->first();
202
+            $query->where('savings.fund_id', $fundId)->first() : $query->whereNull('savings.fund_id')->first();
205 203
         return $saving->total ?? 0;
206 204
     }
207 205
 
@@ -222,8 +220,7 @@  discard block
 block discarded – undo
222 220
             ->where('debts.type', Debt::TYPE_INTEREST)
223 221
             ->whereIn('refunds.session_id', $sessionIds);
224 222
         $refund = $fundId > 0 ?
225
-            $query->where('loans.fund_id', $fundId)->first() :
226
-            $query->whereNull('loans.fund_id')->first();
223
+            $query->where('loans.fund_id', $fundId)->first() : $query->whereNull('loans.fund_id')->first();
227 224
         return $refund->total ?? 0;
228 225
     }
229 226
 
Please login to merge, or discard this patch.
src/Service/Tontine/MemberService.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         // The number of active members is saved in the round, so its current
102 102
         // value can be retrieved forever, even when the membership will change.
103 103
         $round = $this->tenantService->round();
104
-        if(!isset($round->properties['members']))
104
+        if (!isset($round->properties['members']))
105 105
         {
106 106
             // Create and save the property with the content
107 107
             $this->saveActiveMembers();
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             $tontine = $this->tenantService->tontine();
145 145
             $members = $tontine->members()->createMany($values);
146 146
             // Create members bills
147
-            foreach($members as $member)
147
+            foreach ($members as $member)
148 148
             {
149 149
                 $this->memberCreated($tontine, $member);
150 150
             }
Please login to merge, or discard this patch.
src/Service/Planning/SubscriptionService.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
             ->withCount('receivables')
161 161
             ->get()
162 162
             ->sortBy('receivables_count');
163
-        if($subscriptions->count() === 0)
163
+        if ($subscriptions->count() === 0)
164 164
         {
165 165
             throw new MessageException(trans('tontine.subscription.errors.not_found'));
166 166
         }
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public function unsetPayableSession(Subscription $subscription)
211 211
     {
212
-        if(($subscription->payable->session_id))
212
+        if (($subscription->payable->session_id))
213 213
         {
214 214
             $subscription->payable->session()->dissociate();
215 215
             $subscription->payable->save();
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
         $session = $this->tenantService->getSession($sessionId);
233 233
         $currSubscription = null;
234 234
         $nextSubscription = null;
235
-        if($currSubscriptionId > 0)
235
+        if ($currSubscriptionId > 0)
236 236
         {
237 237
             $currSubscription = $pool->subscriptions()->with('payable')->find($currSubscriptionId);
238
-            if(($currSubscription !== null && $currSubscription->payable !== null &&
238
+            if (($currSubscription !== null && $currSubscription->payable !== null &&
239 239
                 $currSubscription->payable->remitment !== null) || $session->closed)
240 240
             {
241 241
                 // Can't chage the beneficiary if the session is closed or if
@@ -243,19 +243,19 @@  discard block
 block discarded – undo
243 243
                 return false;
244 244
             }
245 245
         }
246
-        if($nextSubscriptionId > 0)
246
+        if ($nextSubscriptionId > 0)
247 247
         {
248 248
             $nextSubscription = $pool->subscriptions()->with('payable')->find($nextSubscriptionId);
249 249
         }
250 250
 
251 251
         DB::transaction(function() use($session, $currSubscription, $nextSubscription) {
252 252
             // If the beneficiary already has a session assigned, first remove it.
253
-            if($currSubscription !== null)
253
+            if ($currSubscription !== null)
254 254
             {
255 255
                 $this->unsetPayableSession($currSubscription);
256 256
             }
257 257
             // If there is a new session assigned to the beneficiary, then save it.
258
-            if($nextSubscription !== null)
258
+            if ($nextSubscription !== null)
259 259
             {
260 260
                 $this->setPayableSession($nextSubscription, $session);
261 261
             }
Please login to merge, or discard this patch.
src/Service/Report/Pdf/LocalGenerator.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@
 block discarded – undo
22 22
             $page = $this->browser->createPage();
23 23
             $page->setHtml($html);
24 24
             return $page->pdf($config)->getBase64();
25
-        }
26
-        finally
25
+        } finally
27 26
         {
28 27
             $this->browser->close();
29 28
         }
Please login to merge, or discard this patch.