Completed
Pull Request — master (#14)
by Pavel
04:42
created

ApiFactoryRegistryFactory::has()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Bankiru\Api\Doctrine\ApiFactory;
4
5
use Bankiru\Api\Doctrine\ApiFactoryInterface;
6
use Bankiru\Api\Doctrine\ApiFactoryRegistryInterface;
7
use Bankiru\Api\Doctrine\Exception\MappingException;
8
use Bankiru\Api\Doctrine\Mapping\ApiMetadata;
9
use ScayTrase\Api\Rpc\RpcClientInterface;
10
11
final class ApiFactoryRegistryFactory implements ApiFactoryRegistryInterface
12
{
13
    /** @var  ApiFactoryInterface[] */
14
    private $factories = [];
15
16
    /** {@inheritdoc} */
17 View Code Duplication
    public function create($alias, RpcClientInterface $client, ApiMetadata $metadata)
0 ignored issues
show
Duplication introduced by
This method 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...
18
    {
19
        if (!$this->has($alias)) {
20
            throw MappingException::unknownApiFactory($alias);
21
        }
22
23
        return $this->factories[$alias]->createApi($client, $metadata);
24
    }
25
26
    /** {@inheritdoc} */
27 19
    public function has($alias)
28
    {
29 19
        return array_key_exists($alias, $this->factories);
30
    }
31
32
    /** {@inheritdoc} */
33
    public function set($alias, ApiFactoryInterface $factory)
34
    {
35
        $this->factories[$alias] = $factory;
36
    }
37
}
38