Passed
Push — ft/package ( 5ee474...180175 )
by Philippe
05:16 queued 12s
created

UserPresenter::enabledAsLabel()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.3332

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 0
dl 0
loc 10
ccs 4
cts 6
cp 0.6667
crap 3.3332
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Thinktomorrow\Chief\Users;
4
5
class UserPresenter
6
{
7
    /**
8
     * @var User
9
     */
10
    private $user;
11
12 2
    public function __construct(User $user)
13
    {
14 2
        $this->user = $user;
15 2
    }
16
17 2
    public function enabledAsLabel(): string
18
    {
19
        // Avoid showing enabled state if there is an invitation pending
20 2
        if ($this->user->invitation) {
21
            return '';
22
        }
23
24 2
        return $this->user->isEnabled()
25
            ? ''
26 2
            : '<span class="label label--error">Gebruiker is geblokkeerd.</span>';
27
    }
28
}
29