Completed
Pull Request — master (#274)
by
unknown
63:55 queued 33:13
created

UserPresenter   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 53.85%

Importance

Changes 3
Bugs 2 Features 0
Metric Value
wmc 6
eloc 12
c 3
b 2
f 0
dl 0
loc 27
ccs 7
cts 13
cp 0.5385
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A enabledAsLabel() 0 15 5
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->last()) {
21
            $state = $this->user->invitation->last()->state();
22
            if ($state == 'pending') {
23
                return '<span class="label label-primary">Uitgenodigd</span>';
24
            } elseif ($state == 'denied') {
25
                return '<span class="label label-error">Geblokkeerd</span>';
26
            }
27
        }
28
29 2
        return $this->user->isEnabled()
30
            ? ''
31 2
            : '<span class="label label-error">Geblokkeerd</span>';
32
    }
33
}
34