Completed
Push — master ( 513898...595f7b )
by Łukasz
29:17
created

PlaceholderProviderRegistry::supports()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 4
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the eZ Publish Kernel package.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Bundle\EzPublishCoreBundle\Imagine;
10
11
use InvalidArgumentException;
12
13 View Code Duplication
class PlaceholderProviderRegistry
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    /**
16
     * @var \eZ\Bundle\EzPublishCoreBundle\Imagine\PlaceholderProvider
17
     */
18
    private $providers;
19
20
    /**
21
     * PlaceholderProviderRegistry constructor.
22
     *
23
     * @param array $providers
24
     */
25
    public function __construct(array $providers = [])
26
    {
27
        $this->providers = $providers;
0 ignored issues
show
Documentation Bug introduced by
It seems like $providers of type array is incompatible with the declared type object<eZ\Bundle\EzPubli...ne\PlaceholderProvider> of property $providers.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
28
    }
29
30
    public function addProvider(string $type, PlaceholderProvider $provider)
31
    {
32
        $this->providers[$type] = $provider;
33
    }
34
35
    public function supports(string $type): bool
36
    {
37
        return isset($this->providers[$type]);
38
    }
39
40
    public function getProvider(string $type): PlaceholderProvider
41
    {
42
        if (!$this->supports($type)) {
43
            throw new InvalidArgumentException("Unknown placeholder provider: $type");
44
        }
45
46
        return $this->providers[$type];
47
    }
48
}
49