Passed
Pull Request — main (#55)
by Thierry
05:38
created

Presence::home()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 9
nc 2
nop 0
dl 0
loc 15
rs 9.9666
c 1
b 0
f 0
1
<?php
2
3
namespace App\Ajax\Web\Meeting;
4
5
use App\Ajax\CallableClass;
6
use Siak\Tontine\Service\Meeting\PresenceService;
7
8
use function trans;
9
10
/**
11
 * @databag presence
12
 */
13
class Presence extends CallableClass
14
{
15
    /**
16
     * @var PresenceService
17
     */
18
    protected PresenceService $presenceService;
19
20
    /**
21
     * @before checkRoundSessions
22
     * @after hideMenuOnMobile
23
     */
24
    public function home()
25
    {
26
        $exchange = $this->bag('presence')->get('exchange', false);
27
28
        $this->response->html('section-title', trans('tontine.menus.presences'));
29
        $html = $this->render('pages.meeting.presence.home', ['exchange' => $exchange]);
30
        $this->response->html('content-home', $html);
0 ignored issues
show
Bug introduced by
It seems like $html can also be of type null; however, parameter $sData of Jaxon\Response\Response::html() 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

30
        $this->response->html('content-home', /** @scrutinizer ignore-type */ $html);
Loading history...
31
32
        $this->jq('#btn-presence-exchange')->click($this->rq()->exchange());
33
34
        $this->bag('presence')->set('session.id', 0);
35
        $this->bag('presence')->set('member.id', 0);
36
37
        $className = !$exchange ? Presence\Session::class : Presence\Member::class;
38
        return $this->cl($className)->home();
39
    }
40
41
    public function exchange()
42
    {
43
        $exchange = $this->bag('presence')->get('exchange', false);
44
        $this->bag('presence')->set('exchange', !$exchange);
45
46
        return $this->home();
47
    }
48
49
    /**
50
     * @di $presenceService
51
     */
52
    public function selectSession(int $sessionId)
53
    {
54
        if(!($session = $this->presenceService->getSession($sessionId)))
55
        {
56
            // Todo: show en error message
57
            return $this->response;
58
        }
59
60
        return $this->cl(Presence\Member::class)->show($session);
61
    }
62
63
    /**
64
     * @di $presenceService
65
     */
66
    public function selectMember(int $memberId)
67
    {
68
        if(!($member = $this->presenceService->getMember($memberId)))
69
        {
70
            // Todo: show en error message
71
            return $this->response;
72
        }
73
74
        return $this->cl(Presence\Session::class)->show($member);
75
    }
76
}
77