Binding   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
c 1
b 0
f 1
dl 0
loc 35
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A getConstraints() 0 3 1
A __construct() 0 4 1
A unnamed() 0 3 1
A named() 0 3 1
A isNamed() 0 3 1
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
It seems like you are loosely comparing $this->getName() of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
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