Completed
Push — master ( 586888...6f962e )
by Kamil
14s
created

ResolverServiceRegistry::all()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\SettingsBundle\Resolver;
13
14
use Sylius\Component\Registry\NonExistingServiceException;
15
use Sylius\Component\Registry\ServiceRegistry;
16
use Sylius\Component\Registry\ServiceRegistryInterface;
17
18
/**
19
 * @author Steffen Brem <[email protected]>
20
 */
21
final class ResolverServiceRegistry implements ServiceRegistryInterface
22
{
23
    /**
24
     * @var ServiceRegistryInterface
25
     */
26
    private $decoratedRegistry;
27
28
    /**
29
     * @var SettingsResolverInterface
30
     */
31
    private $defaultResolver;
32
33
    /**
34
     * @param ServiceRegistryInterface $decoratedRegistry
35
     * @param SettingsResolverInterface $defaultResolver
36
     */
37
    public function __construct(ServiceRegistryInterface $decoratedRegistry, SettingsResolverInterface $defaultResolver)
38
    {
39
        $this->decoratedRegistry = $decoratedRegistry;
40
        $this->defaultResolver = $defaultResolver;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function all()
47
    {
48
        return $this->decoratedRegistry->all();
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function register($type, $service)
55
    {
56
        $this->decoratedRegistry->register($type, $service);
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function unregister($type)
63
    {
64
        $this->decoratedRegistry->unregister($type);
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function has($type)
71
    {
72
        return $this->decoratedRegistry->has($type);
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function get($type)
79
    {
80
        if (!$this->decoratedRegistry->has($type)) {
81
            return $this->defaultResolver;
82
        }
83
84
        return $this->decoratedRegistry->get($type);
85
    }
86
}
87