1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Limoncello\Auth\Authorization\PolicyAdministration; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Copyright 2015-2019 [email protected] |
7
|
|
|
* |
8
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
9
|
|
|
* you may not use this file except in compliance with the License. |
10
|
|
|
* You may obtain a copy of the License at |
11
|
|
|
* |
12
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
13
|
|
|
* |
14
|
|
|
* Unless required by applicable law or agreed to in writing, software |
15
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
16
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17
|
|
|
* See the License for the specific language governing permissions and |
18
|
|
|
* limitations under the License. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
use Limoncello\Auth\Contracts\Authorization\PolicyAdministration\AnyOfInterface; |
22
|
|
|
use Limoncello\Auth\Contracts\Authorization\PolicyAdministration\TargetInterface; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @package Limoncello\Auth |
26
|
|
|
*/ |
27
|
|
|
class Target implements TargetInterface |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @var null|string |
31
|
|
|
*/ |
32
|
|
|
private $name; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var AnyOfInterface |
36
|
|
|
*/ |
37
|
|
|
private $anyOff; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param AnyOfInterface $anyOff |
41
|
30 |
|
* @param string|null $name |
42
|
|
|
*/ |
43
|
30 |
|
public function __construct(AnyOfInterface $anyOff, string $name = null) |
44
|
|
|
{ |
45
|
|
|
$this->setAnyOff($anyOff)->setName($name); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
30 |
|
* @inheritdoc |
50
|
|
|
*/ |
51
|
30 |
|
public function getAnyOf(): AnyOfInterface |
52
|
|
|
{ |
53
|
|
|
return $this->anyOff; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
30 |
|
* @inheritdoc |
58
|
|
|
*/ |
59
|
30 |
|
public function getName(): ?string |
60
|
|
|
{ |
61
|
|
|
return $this->name; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param null|string $name |
66
|
|
|
* |
67
|
30 |
|
* @return $this |
68
|
|
|
*/ |
69
|
30 |
|
public function setName(?string $name) |
70
|
|
|
{ |
71
|
30 |
|
$this->name = $name; |
72
|
|
|
|
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param AnyOfInterface $anyOff |
78
|
|
|
* |
79
|
30 |
|
* @return self |
80
|
|
|
*/ |
81
|
30 |
|
public function setAnyOff(AnyOfInterface $anyOff): self |
82
|
|
|
{ |
83
|
30 |
|
$this->anyOff = $anyOff; |
84
|
|
|
|
85
|
|
|
return $this; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|