1 | <?php |
||
2 | /** |
||
3 | * Created by enea dhack - 17/06/2020 17:03. |
||
4 | */ |
||
5 | |||
6 | namespace Vaened\Searcher; |
||
7 | |||
8 | final class Binding |
||
9 | { |
||
10 | private ?string $name; |
||
11 | |||
12 | private array $constraints; |
||
13 | |||
14 | public function __construct(?string $name, array $constraints) |
||
15 | { |
||
16 | $this->name = $name; |
||
17 | $this->constraints = $constraints; |
||
18 | } |
||
19 | |||
20 | public static function named(string $name, array $constraints): Binding |
||
21 | { |
||
22 | return new static($name, $constraints); |
||
23 | } |
||
24 | |||
25 | public static function unnamed(Constraint $constraint): Binding |
||
26 | { |
||
27 | return new static(null, [$constraint]); |
||
28 | } |
||
29 | |||
30 | public function isNamed(): bool |
||
31 | { |
||
32 | return $this->getName() != null; |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
33 | } |
||
34 | |||
35 | public function getName(): ?string |
||
36 | { |
||
37 | return $this->name; |
||
38 | } |
||
39 | |||
40 | public function getConstraints(): array |
||
41 | { |
||
42 | return $this->constraints; |
||
43 | } |
||
44 | } |
||
45 |