Completed
Push — master ( c8e320...41a25f )
by Mike
03:33
created

BusinessLocatorProxy   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 15
dl 0
loc 43
c 0
b 0
f 0
ccs 13
cts 13
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A facade() 0 10 3
A factory() 0 11 3
1
<?php
2
declare(strict_types=1);
3
4
namespace Xervice\Core\Business\Model\Locator\Proxy\Business;
5
6
7
use Xervice\Core\Business\Model\Facade\AbstractFacade;
8
use Xervice\Core\Business\Model\Facade\FacadeInterface;
9
use Xervice\Core\Business\Model\Factory\AbstractBusinessFactory;
10
use Xervice\Core\Business\Model\Factory\FactoryInterface;
11
use Xervice\Core\Business\Model\Locator\Proxy\AbstractLocatorProxy;
12
13
class BusinessLocatorProxy extends AbstractLocatorProxy
14
{
15
    private const DIRECTORY = 'Business';
16
17
    /**
18
     * @var \Xervice\Core\Business\Model\Factory\FactoryInterface
19
     */
20
    private $factory;
21
22
    /**
23
     * @var \Xervice\Core\Business\Model\Facade\FacadeInterface
24
     */
25
    private $facade;
26
27
    /**
28
     * @return \Xervice\Core\Business\Model\Factory\FactoryInterface
29
     */
30 4
    public function factory(): FactoryInterface
31
    {
32 4
        if ($this->factory === null) {
33 2
            $class = $this->getServiceClass('BusinessFactory', self::DIRECTORY) ?: AbstractBusinessFactory::class;
34 2
            $this->factory = new $class(
35 2
                $this->config(),
36 2
                $this->container()
37
            );
38
        }
39
40 4
        return $this->factory;
41
    }
42
43
    /**
44
     * @return \Xervice\Core\Business\Model\Facade\FacadeInterface
45
     */
46 3
    public function facade(): FacadeInterface
47
    {
48 3
        if ($this->facade === null) {
49 2
            $class = $this->getServiceClass('Facade', self::DIRECTORY) ?: AbstractFacade::class;
50 2
            $this->facade = new $class(
51 2
                $this->factory()
52
            );
53
        }
54
55 3
        return $this->facade;
56
    }
57
}