Passed
Pull Request — main (#51)
by Thierry
13:39
created
src/Validation/Planning/SessionValidator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
             'end' => 'required|date_format:H:i',
23 23
             'host_id' => 'integer|min:0',
24 24
         ]);
25
-        if($validator->fails())
25
+        if ($validator->fails())
26 26
         {
27 27
             throw new ValidationException($validator);
28 28
         }
29 29
 
30 30
         $validated = $validator->validated();
31
-        if(!$validated['host_id'])
31
+        if (!$validated['host_id'])
32 32
         {
33 33
             $validated['host_id'] = null;
34 34
         }
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
             'venue' => 'nullable|string',
47 47
             'notes' => 'nullable|string',
48 48
         ]);
49
-        if($validator->fails())
49
+        if ($validator->fails())
50 50
         {
51 51
             throw new ValidationException($validator);
52 52
         }
Please login to merge, or discard this patch.
src/Validation/AbstractValidator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
     protected function values(array $values): array
19 19
     {
20 20
         return array_map(function($value) {
21
-            if(!is_string($value))
21
+            if (!is_string($value))
22 22
             {
23 23
                 return $value;
24 24
             }
Please login to merge, or discard this patch.
src/Service/BalanceCalculator.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function getReceivableAmount(Receivable $receivable): int
37 37
     {
38
-        if($receivable->subscription->pool->deposit_fixed)
38
+        if ($receivable->subscription->pool->deposit_fixed)
39 39
         {
40 40
             return $receivable->subscription->pool->amount;
41 41
         }
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
     public function getPayableAmount(Payable $payable, Session $session): int
99 99
     {
100 100
         $pool = $payable->subscription->pool;
101
-        if($pool->remit_fixed)
101
+        if ($pool->remit_fixed)
102 102
         {
103
-            if($pool->deposit_fixed)
103
+            if ($pool->deposit_fixed)
104 104
             {
105 105
                 return $pool->amount * $this->tenantService->countEnabledSessions($pool);
106 106
             }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function getPoolRemitmentAmount(Pool $pool, Session $session): int
129 129
     {
130
-        if(!$pool->remit_fixed)
130
+        if (!$pool->remit_fixed)
131 131
         {
132 132
             // Sum the amounts for all remitments
133 133
             return $this->getRemitmentQuery(false)
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
                 ->where('subscriptions.pool_id', $pool->id)
136 136
                 ->sum('remitments.amount');
137 137
         }
138
-        if(!$pool->deposit_fixed)
138
+        if (!$pool->deposit_fixed)
139 139
         {
140 140
             // Sum the amounts for all deposits
141 141
             return $this->getPoolDepositAmount($pool, $session);
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         return DB::table('partial_refunds')
276 276
             ->join('debts', 'partial_refunds.debt_id', '=', 'debts.id')
277 277
             ->whereIn('partial_refunds.session_id', $sessionIds)
278
-            ->whereNotExists(function (Builder $query) {
278
+            ->whereNotExists(function(Builder $query) {
279 279
                 $query->select(DB::raw(1))->from('refunds')
280 280
                     ->whereColumn('refunds.debt_id', 'debts.id');
281 281
             })
Please login to merge, or discard this patch.
src/Service/Meeting/SummaryService.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $cashier = 0;
59 59
         $collectedFigures = [];
60
-        foreach($sessions as $session)
60
+        foreach ($sessions as $session)
61 61
         {
62
-            if($session->disabled($pool) || $session->pending)
62
+            if ($session->disabled($pool) || $session->pending)
63 63
             {
64 64
                 $collectedFigures[$session->id] = $this->makeFigures(' ');
65 65
                 continue;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
             });
110 110
         $sessions = $this->_getSessions($pool, ['payables.remitment']);
111 111
         $figures = new stdClass();
112
-        if($pool->remit_planned)
112
+        if ($pool->remit_planned)
113 113
         {
114 114
             $figures->expected = $this->getExpectedFigures($pool, $sessions, $subscriptions);
115 115
         }
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 
134 134
         $figures = [];
135 135
         $position = 0;
136
-        foreach($sessions as $session)
136
+        foreach ($sessions as $session)
137 137
         {
138 138
             $figures[$session->id] = new stdClass();
139 139
             $figures[$session->id]->payables = $session->payables;
140 140
             $figures[$session->id]->count = 0;
141 141
             $figures[$session->id]->amount = '';
142
-            if($session->enabled($pool))
142
+            if ($session->enabled($pool))
143 143
             {
144 144
                 $figures[$session->id]->count =
145 145
                     $this->getRemitmentCount($sessionCount, $subscriptionCount, $position++);
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      */
159 159
     public function getSessionRemitmentCount(Pool $pool, Session $session): int
160 160
     {
161
-        if(!$pool->deposit_fixed)
161
+        if (!$pool->deposit_fixed)
162 162
         {
163 163
             return 1;
164 164
         }
Please login to merge, or discard this patch.
src/Service/Meeting/Pool/RemitmentService.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
             ->each(function($payable) use($session) {
120 120
                 $payable->amount = $this->balanceCalculator->getPayableAmount($payable, $session);
121 121
             });
122
-        if(!$pool->remit_planned)
122
+        if (!$pool->remit_planned)
123 123
         {
124 124
             return $payables;
125 125
         }
126 126
 
127 127
         // When the number of remitments is planned, the list is padded to the expected number.
128 128
         $remitmentCount = $this->summaryService->getSessionRemitmentCount($pool, $session);
129
-        $emptyPayable = (object)[
129
+        $emptyPayable = (object) [
130 130
             'id' => 0,
131 131
             'amount' => $pool->amount * $this->tenantService->countEnabledSessions($pool),
132 132
             'remitment' => null,
@@ -161,18 +161,18 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function savePlannedRemitment(Pool $pool, Session $session, int $payableId): void
163 163
     {
164
-        if(!$pool->remit_planned || $pool->remit_auction)
164
+        if (!$pool->remit_planned || $pool->remit_auction)
165 165
         {
166 166
             // Only when remitments are planned and without auctions.
167 167
             return;
168 168
         }
169 169
         // The payable is supposed to already have been associated to the session.
170 170
         $payable = $this->getPayable($pool, $session, $payableId);
171
-        if(!$payable)
171
+        if (!$payable)
172 172
         {
173 173
             throw new MessageException(trans('tontine.subscription.errors.not_found'));
174 174
         }
175
-        if($payable->remitment)
175
+        if ($payable->remitment)
176 176
         {
177 177
             return;
178 178
         }
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
             ->whereDoesntHave('remitment')
200 200
             ->whereIn('subscription_id', $pool->subscriptions()->pluck('id'))
201 201
             ->find($payableId);
202
-        if(!$payable)
202
+        if (!$payable)
203 203
         {
204 204
             throw new MessageException(trans('tontine.subscription.errors.not_found'));
205 205
         }
206
-        if($payable->session_id !== null && $payable->session_id !== $session->id)
206
+        if ($payable->session_id !== null && $payable->session_id !== $session->id)
207 207
         {
208 208
             // The selected member is already planned on another session.
209 209
             throw new MessageException(trans('tontine.remitment.errors.planning'));
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
             // Create the remitment.
217 217
             $remitment = $payable->remitment()->create(['amount' => $amount]);
218 218
 
219
-            if($pool->remit_auction && $auction > 0)
219
+            if ($pool->remit_auction && $auction > 0)
220 220
             {
221 221
                 // Create the corresponding auction.
222 222
                 Auction::create([
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         $payable = $this->getQuery($pool, $session)
244 244
             ->with(['remitment', 'remitment.auction'])
245 245
             ->find($payableId);
246
-        if(!$payable || !($remitment = $payable->remitment))
246
+        if (!$payable || !($remitment = $payable->remitment))
247 247
         {
248 248
             return;
249 249
         }
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
             $remitment->auction()->delete();
254 254
             $remitment->delete();
255 255
             // Detach from the session, but only if the remitment was not planned.
256
-            if(!$pool->remit_planned || $pool->remit_auction)
256
+            if (!$pool->remit_planned || $pool->remit_auction)
257 257
             {
258 258
                 $payable->session()->dissociate();
259 259
                 $payable->save();
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
     public function getSubscriptions(Pool $pool, Session $session): Collection
273 273
     {
274 274
         $subscriptions = $pool->subscriptions()->with(['payable', 'member'])->get();
275
-        if($pool->remit_planned && !$pool->remit_auction)
275
+        if ($pool->remit_planned && !$pool->remit_auction)
276 276
         {
277 277
             // Only the beneficiaries planned for this session.
278 278
             return $subscriptions
Please login to merge, or discard this patch.
app/Ajax/Web/Report/Session.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
                 return $session->opened;
35 35
             })
36 36
             ->pluck('title', 'id');
37
-        if($sessions->count() === 0)
37
+        if ($sessions->count() === 0)
38 38
         {
39 39
             return $this->response;
40 40
         }
41 41
         $members = $this->tontineService->getMembers();
42
-        if($members->count() === 0)
42
+        if ($members->count() === 0)
43 43
         {
44 44
             return $this->response;
45 45
         }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
     public function showSession(int $sessionId)
70 70
     {
71
-        if(!($session = $this->tenantService->getSession($sessionId)))
71
+        if (!($session = $this->tenantService->getSession($sessionId)))
72 72
         {
73 73
             return $this->response;
74 74
         }
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 
82 82
     public function showMember(int $sessionId, int $memberId)
83 83
     {
84
-        if(!($session = $this->tenantService->getSession($sessionId)))
84
+        if (!($session = $this->tenantService->getSession($sessionId)))
85 85
         {
86 86
             return $this->response;
87 87
         }
88
-        if(!($member = $this->tontineService->getMember($memberId)))
88
+        if (!($member = $this->tontineService->getMember($memberId)))
89 89
         {
90 90
             return $this->response;
91 91
         }
Please login to merge, or discard this patch.
app/helpers.php 1 patch
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,12 +35,11 @@
 block discarded – undo
35 35
 {
36 36
     $icon = '<i class="fa fa-toggle-off"></i>';
37 37
     $linkClass = "btn-add-$name";
38
-    if(($payment))
38
+    if (($payment))
39 39
     {
40 40
         $icon = '<i class="fa fa-toggle-on"></i>';
41 41
         $linkClass = "btn-del-$name";
42 42
     }
43 43
 
44
-    return $disableLink ? $icon :
45
-        '<a href="javascript:void(0)" class="' . $linkClass . '">' . $icon . '</a>';
44
+    return $disableLink ? $icon : '<a href="javascript:void(0)" class="' . $linkClass . '">' . $icon . '</a>';
46 45
 }
Please login to merge, or discard this patch.
app/Ajax/Web/Meeting/Pool/Deposit/Pool.php 1 patch
Spacing   +14 added lines, -16 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             $this->target()->args()[0] : $this->bag('meeting')->get('pool.id');
69 69
         $this->pool = $this->depositService->getPool($poolId);
70 70
 
71
-        if(!$this->session || !$this->pool || $this->session->disabled($this->pool))
71
+        if (!$this->session || !$this->pool || $this->session->disabled($this->pool))
72 72
         {
73 73
             $this->notify->error(trans('tontine.session.errors.disabled'), trans('common.titles.error'));
74 74
             $this->pool = null;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public function addDeposit(int $receivableId)
136 136
     {
137
-        if($this->session->closed)
137
+        if ($this->session->closed)
138 138
         {
139 139
             $this->notify->warning(trans('meeting.warnings.session.closed'));
140 140
             return $this->response;
@@ -153,21 +153,20 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public function editAmount(int $receivableId)
155 155
     {
156
-        if($this->session->closed)
156
+        if ($this->session->closed)
157 157
         {
158 158
             $this->notify->warning(trans('meeting.warnings.session.closed'));
159 159
             return $this->response;
160 160
         }
161 161
         $receivable = $this->depositService->getReceivable($this->pool, $this->session, $receivableId);
162
-        if(!$receivable || !$receivable->deposit)
162
+        if (!$receivable || !$receivable->deposit)
163 163
         {
164 164
             return $this->page();
165 165
         }
166 166
 
167 167
         $html = $this->view()->render('tontine.pages.meeting.deposit.libre.edit', [
168 168
             'id' => $receivable->id,
169
-            'amount' => !$receivable->deposit ? '' :
170
-                $this->localeService->getMoneyValue($receivable->deposit->amount),
169
+            'amount' => !$receivable->deposit ? '' : $this->localeService->getMoneyValue($receivable->deposit->amount),
171 170
         ]);
172 171
         $fieldId = 'receivable-' . $receivable->id;
173 172
         $this->response->html($fieldId, $html);
@@ -188,22 +187,21 @@  discard block
 block discarded – undo
188 187
      */
189 188
     public function saveAmount(int $receivableId, string $amount)
190 189
     {
191
-        if($this->session->closed)
190
+        if ($this->session->closed)
192 191
         {
193 192
             $this->notify->warning(trans('meeting.warnings.session.closed'));
194 193
             return $this->response;
195 194
         }
196 195
         $amount = str_replace(',', '.', trim($amount));
197
-        if($amount !== '' && filter_var($amount, FILTER_VALIDATE_FLOAT) === false)
196
+        if ($amount !== '' && filter_var($amount, FILTER_VALIDATE_FLOAT) === false)
198 197
         {
199 198
             $this->notify->error(trans('meeting.errors.amount.invalid', ['amount' => $amount]));
200 199
             return $this->response;
201 200
         }
202
-        $amount = $amount === '' ? 0 : $this->localeService->convertMoneyToInt((float)$amount);
201
+        $amount = $amount === '' ? 0 : $this->localeService->convertMoneyToInt((float) $amount);
203 202
 
204 203
         $amount > 0 ?
205
-            $this->depositService->saveDepositAmount($this->pool, $this->session, $receivableId, $amount):
206
-            $this->depositService->deleteDeposit($this->pool, $this->session, $receivableId);
204
+            $this->depositService->saveDepositAmount($this->pool, $this->session, $receivableId, $amount) : $this->depositService->deleteDeposit($this->pool, $this->session, $receivableId);
207 205
 
208 206
         return $this->page();
209 207
     }
@@ -215,7 +213,7 @@  discard block
 block discarded – undo
215 213
      */
216 214
     public function delDeposit(int $receivableId)
217 215
     {
218
-        if($this->session->closed)
216
+        if ($this->session->closed)
219 217
         {
220 218
             $this->notify->warning(trans('meeting.warnings.session.closed'));
221 219
             return $this->response;
@@ -231,12 +229,12 @@  discard block
 block discarded – undo
231 229
      */
232 230
     public function addAllDeposits()
233 231
     {
234
-        if($this->session->closed)
232
+        if ($this->session->closed)
235 233
         {
236 234
             $this->notify->warning(trans('meeting.warnings.session.closed'));
237 235
             return $this->response;
238 236
         }
239
-        if(!$this->pool->deposit_fixed)
237
+        if (!$this->pool->deposit_fixed)
240 238
         {
241 239
             return $this->response;
242 240
         }
@@ -251,12 +249,12 @@  discard block
 block discarded – undo
251 249
      */
252 250
     public function delAllDeposits()
253 251
     {
254
-        if($this->session->closed)
252
+        if ($this->session->closed)
255 253
         {
256 254
             $this->notify->warning(trans('meeting.warnings.session.closed'));
257 255
             return $this->response;
258 256
         }
259
-        if(!$this->pool->deposit_fixed)
257
+        if (!$this->pool->deposit_fixed)
260 258
         {
261 259
             return $this->response;
262 260
         }
Please login to merge, or discard this patch.
src/Service/Meeting/Credit/ProfitService.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -55,26 +55,26 @@  discard block
 block discarded – undo
55 55
     private function setDistributions(Session $session, Collection $fundings): Collection
56 56
     {
57 57
         // Set fundings durations and distributions
58
-        foreach($fundings as $funding)
58
+        foreach ($fundings as $funding)
59 59
         {
60 60
             $funding->duration = $this->getFundingDuration($session, $funding);
61 61
             $funding->distribution = $funding->amount * $funding->duration;
62 62
         }
63 63
         // Reduce the distributions
64
-        $distributionGcd = (int)$fundings->reduce(function($gcd, $funding) {
65
-            if($gcd === 0)
64
+        $distributionGcd = (int) $fundings->reduce(function($gcd, $funding) {
65
+            if ($gcd === 0)
66 66
             {
67 67
                 return $funding->distribution;
68 68
             }
69
-            if($funding->duration === 0)
69
+            if ($funding->duration === 0)
70 70
             {
71 71
                 return $gcd;
72 72
             }
73 73
             return gmp_gcd($gcd, $funding->distribution);
74 74
         }, $fundings->first()->distribution);
75
-        if($distributionGcd > 0)
75
+        if ($distributionGcd > 0)
76 76
         {
77
-            foreach($fundings as $funding)
77
+            foreach ($fundings as $funding)
78 78
             {
79 79
                 $funding->distribution /= $distributionGcd;
80 80
             }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             ->orderBy('members.name', 'asc')
102 102
             ->orderBy('sessions.start_at', 'asc')
103 103
             ->with(['session', 'member'])->get();
104
-        if($fundings->count() === 0)
104
+        if ($fundings->count() === 0)
105 105
         {
106 106
             return $fundings;
107 107
         }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             'amount' => $profitAmount,
149 149
         ];
150 150
         $round = $this->tenantService->round();
151
-        if($round->property !== null)
151
+        if ($round->property !== null)
152 152
         {
153 153
             $content = $round->property->content;
154 154
             $content['profit'] = $profit;
Please login to merge, or discard this patch.