Binding::isNamed()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
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