Passed
Pull Request — main (#4)
by Michael
11:30
created

Forwarding::enable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MichaelRubel\EnhancedContainer\Core;
6
7
class Forwarding
8
{
9
    public const CONTAINER_KEY = '_forwarding';
10
11
    /**
12
     * @var string
13
     */
14
    public string $pendingClass;
15
16
    /**
17
     * @return static
18
     */
19 10
    public static function enable(): static
20
    {
21 10
        return new static();
22
    }
23
24
    /**
25
     * @param  string  $class
26
     *
27
     * @return $this
28
     */
29 10
    public function from(string $class): static
30
    {
31 10
        $this->pendingClass = $class;
32
33 10
        return $this;
34
    }
35
36
    /**
37
     * @param  string  $destination
38
     *
39
     * @return $this
40
     */
41 10
    public function to(string $destination): static
42
    {
43 10
        app()->singleton($this->pendingClass . static::CONTAINER_KEY, $destination);
44
45 10
        return $this;
46
    }
47
}
48