User   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 3
cbo 1
dl 0
loc 69
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A withSupportContactEmail() 0 7 1
A switchLocaleTo() 0 4 1
A hasSupportContactEmail() 0 4 1
A getSupportContactEmail() 0 4 1
A getLocale() 0 4 1
A getAttributes() 0 4 1
A getId() 0 4 1
1
<?php
2
3
/**
4
 * Copyright 2015 SURFnet B.V.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace OpenConext\Profile\Entity;
20
21
use OpenConext\Profile\Api\ApiUserInterface;
22
use OpenConext\Profile\Value\ContactEmailAddress;
23
use OpenConext\Profile\Value\Locale;
24
25
final class User implements ApiUserInterface
26
{
27
    /**
28
     * @var AuthenticatedUser
29
     */
30
    private $authenticatedUser;
31
32
    /**
33
     * @var Locale
34
     */
35
    private $locale;
36
37
    /**
38
     * @var ContactEmailAddress|null
39
     */
40
    private $supportContactEmail;
41
42
    /**
43
     * @param AuthenticatedUser $authenticatedUser
44
     * @param Locale $locale
45
     */
46
    public function __construct(AuthenticatedUser $authenticatedUser, Locale $locale)
47
    {
48
        $this->authenticatedUser = $authenticatedUser;
49
        $this->locale            = $locale;
50
    }
51
52
    /**
53
     * @param ContactEmailAddress $supportContactEmail
54
     * @return UserInterface
0 ignored issues
show
Documentation introduced by
Should the return type not be User?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
55
     */
56
    public function withSupportContactEmail(ContactEmailAddress $supportContactEmail)
57
    {
58
        $newUser = clone $this;
59
        $newUser->supportContactEmail = $supportContactEmail;
60
61
        return $newUser;
62
    }
63
64
    public function switchLocaleTo(Locale $locale)
65
    {
66
        $this->locale = $locale;
67
    }
68
69
    public function hasSupportContactEmail()
70
    {
71
        return $this->supportContactEmail !== null;
72
    }
73
74
    public function getSupportContactEmail()
75
    {
76
        return $this->supportContactEmail;
77
    }
78
79
    public function getLocale()
80
    {
81
        return $this->locale;
82
    }
83
84
    public function getAttributes()
85
    {
86
        return $this->authenticatedUser->getAttributesFiltered();
87
    }
88
89
    public function getId()
90
    {
91
        return $this->authenticatedUser->getNameId();
92
    }
93
}
94