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

UserPresenter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A enabledAsLabel() 0 10 3
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