UserRegistrationResult::getTenant()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace JincorTech\AuthClient;
4
5
use InvalidArgumentException;
6
use JincorTech\AuthClient\Abstracts\RegistrationResult;
7
8
/**
9
 * Class UserRegistrationResult.
10
 */
11
class UserRegistrationResult extends RegistrationResult
12
{
13
    /**
14
     * @var string
15
     */
16
    private $tenant;
17
18
    /**
19
     * @var string
20
     */
21
    private $scope;
22
23
    /**
24
     * @var string
25
     */
26
    private $sub;
27
28
    /**
29
     * UserRegistrationResult constructor.
30
     *
31
     * @param array $params
32
     */
33 View Code Duplication
    public function __construct(array $params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        parent::__construct($params);
36
37
        $this->validateParams($params, ['tenant', 'sub']);
38
39
        $this->setTenant($params['tenant']);
40
        $this->setSub($params['sub']);
41
        $this->setScope($params['scope'] ?? '');
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getTenant(): string
48
    {
49
        return $this->tenant;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getScope(): string
56
    {
57
        return $this->scope;
58
    }
59
60
    /**
61
     * @return string
62
     */
63
    public function getSub(): string
64
    {
65
        return $this->sub;
66
    }
67
68
    /**
69
     * @param string $tenant
70
     */
71
    private function setTenant(string $tenant)
72
    {
73
        if (empty($tenant)) {
74
            throw new InvalidArgumentException('Tenant value can not be empty');
75
        }
76
77
        $this->tenant = $tenant;
78
    }
79
80
    /**
81
     * @param string $scope
82
     */
83
    private function setScope(string $scope)
84
    {
85
        $this->scope = $scope;
86
    }
87
88
    /**
89
     * @param string $sub
90
     */
91
    private function setSub(string $sub)
92
    {
93
        if (empty($sub)) {
94
            throw new InvalidArgumentException('Sub value can not be empty');
95
        }
96
97
        $this->sub = $sub;
98
    }
99
}
100