Passed
Pull Request — master (#1077)
by Maxim
09:56
created

Proxy::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.1481

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 6
ccs 2
cts 3
cp 0.6667
rs 10
cc 2
nc 2
nop 2
crap 2.1481
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Core\Config;
6
7
class Proxy extends Binding
8
{
9
    /**
10
     * @param class-string $interface
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string.
Loading history...
11
     */
12 5
    public function __construct(
13
        protected readonly string $interface,
14
        public readonly bool $singleton = false,
15
    ) {
16 5
        if (!\interface_exists($interface)) {
17
            throw new \InvalidArgumentException(\sprintf('Interface `%s` does not exist.', $interface));
18
        }
19
    }
20
21
    public function __toString(): string
22
    {
23
        return \sprintf('Proxy to `%s`', $this->interface);
24
    }
25
26
    /**
27
     * @return class-string
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string.
Loading history...
28
     */
29 4
    public function getInterface(): string
30
    {
31 4
        return $this->interface;
32
    }
33
}
34