Passed
Push — master ( 72934f...dfb406 )
by Aleksei
05:59 queued 26s
created

Proxy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
eloc 5
c 2
b 1
f 0
dl 0
loc 25
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getInterface() 0 3 1
A __toString() 0 3 1
A __construct() 0 6 2
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 7
    public function __construct(
13
        protected readonly string $interface,
14
        public readonly bool $singleton = false,
15
    ) {
16 7
        if (!\interface_exists($interface)) {
17 1
            throw new \InvalidArgumentException(\sprintf('Interface `%s` does not exist.', $interface));
18
        }
19
    }
20
21 1
    public function __toString(): string
22
    {
23 1
        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