Passed
Push — main ( 936852...10149e )
by Thierry
15:09
created

Session::showBalanceDetails()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 1
dl 0
loc 16
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace App\Ajax\Web\Meeting\Session;
4
5
use App\Ajax\CallableSessionClass;
6
use Siak\Tontine\Service\BalanceCalculator;
7
use Siak\Tontine\Service\LocaleService;
8
9
use function trans;
10
11
class Session extends CallableSessionClass
12
{
13
    /**
14
     * @var LocaleService
15
     */
16
    protected LocaleService $localeService;
17
18
    /**
19
     * @param BalanceCalculator $balanceCalculator
20
     */
21
    public function __construct(private BalanceCalculator $balanceCalculator)
22
    {}
23
24
    /**
25
     * @di $localeService
26
     */
27
    public function showBalanceAmounts()
28
    {
29
        $amount = $this->balanceCalculator->getBalanceForLoan($this->session);
0 ignored issues
show
Bug introduced by
It seems like $this->session can also be of type null; however, parameter $session of Siak\Tontine\Service\Bal...or::getBalanceForLoan() does only seem to accept Siak\Tontine\Model\Session, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

29
        $amount = $this->balanceCalculator->getBalanceForLoan(/** @scrutinizer ignore-type */ $this->session);
Loading history...
30
        $html = trans('meeting.loan.labels.amount_available', [
31
            'amount' => $this->localeService->formatMoney($amount),
32
        ]);
33
        $this->response->html('loan_amount_available', $html);
34
35
        $amount = $this->balanceCalculator->getTotalBalance($this->session);
0 ignored issues
show
Bug introduced by
It seems like $this->session can also be of type null; however, parameter $session of Siak\Tontine\Service\Bal...ator::getTotalBalance() does only seem to accept Siak\Tontine\Model\Session, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
        $amount = $this->balanceCalculator->getTotalBalance(/** @scrutinizer ignore-type */ $this->session);
Loading history...
36
        $html = trans('meeting.disbursement.labels.amount_available', [
37
            'amount' => $this->localeService->formatMoney($amount),
38
        ]);
39
        $this->response->html('total_amount_available', $html);
40
41
        return $this->response;
42
    }
43
44
    public function showBalanceDetails(bool $lendable)
45
    {
46
        $balances = $this->balanceCalculator->getBalances($this->session, $lendable);
0 ignored issues
show
Bug introduced by
It seems like $this->session can also be of type null; however, parameter $session of Siak\Tontine\Service\Bal...lculator::getBalances() does only seem to accept Siak\Tontine\Model\Session, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

46
        $balances = $this->balanceCalculator->getBalances(/** @scrutinizer ignore-type */ $this->session, $lendable);
Loading history...
47
        $title = trans('meeting.titles.amounts');
48
        $content = $this->render('pages.meeting.session.balances', [
49
            'session' => $this->session,
50
            'balances' => $balances,
51
        ]);
52
        $buttons = [[
53
            'title' => trans('common.actions.close'),
54
            'class' => 'btn btn-tertiary',
55
            'click' => 'close',
56
        ]];
57
        $this->dialog->show($title, $content, $buttons);
0 ignored issues
show
Bug introduced by
It seems like $content can also be of type null; however, parameter $sContent of Jaxon\App\Dialog\ModalInterface::show() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

57
        $this->dialog->show($title, /** @scrutinizer ignore-type */ $content, $buttons);
Loading history...
58
59
        return $this->response;
60
    }
61
62
    public function open()
63
    {
64
        $this->sessionService->openSession($this->session);
0 ignored issues
show
Bug introduced by
It seems like $this->session can also be of type null; however, parameter $session of Siak\Tontine\Service\Mee...nService::openSession() does only seem to accept Siak\Tontine\Model\Session, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

64
        $this->sessionService->openSession(/** @scrutinizer ignore-type */ $this->session);
Loading history...
65
        $this->cl(Home::class)->show($this->session);
66
67
        return $this->response;
68
    }
69
70
    public function close()
71
    {
72
        $this->sessionService->closeSession($this->session);
0 ignored issues
show
Bug introduced by
It seems like $this->session can also be of type null; however, parameter $session of Siak\Tontine\Service\Mee...Service::closeSession() does only seem to accept Siak\Tontine\Model\Session, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

72
        $this->sessionService->closeSession(/** @scrutinizer ignore-type */ $this->session);
Loading history...
73
        $this->cl(Home::class)->show($this->session);
74
75
        return $this->response;
76
    }
77
78
    public function saveAgenda(string $text)
79
    {
80
        $this->sessionService->saveAgenda($this->session, $text);
0 ignored issues
show
Bug introduced by
It seems like $this->session can also be of type null; however, parameter $session of Siak\Tontine\Service\Mee...onService::saveAgenda() does only seem to accept Siak\Tontine\Model\Session, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

80
        $this->sessionService->saveAgenda(/** @scrutinizer ignore-type */ $this->session, $text);
Loading history...
81
        $this->notify->success(trans('meeting.messages.agenda.updated'), trans('common.titles.success'));
82
83
        return $this->response;
84
    }
85
86
    public function saveReport(string $text)
87
    {
88
        $this->sessionService->saveReport($this->session, $text);
0 ignored issues
show
Bug introduced by
It seems like $this->session can also be of type null; however, parameter $session of Siak\Tontine\Service\Mee...onService::saveReport() does only seem to accept Siak\Tontine\Model\Session, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

88
        $this->sessionService->saveReport(/** @scrutinizer ignore-type */ $this->session, $text);
Loading history...
89
        $this->notify->success(trans('meeting.messages.report.updated'), trans('common.titles.success'));
90
91
        return $this->response;
92
    }
93
}
94