ServiceIdDecorator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 35
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A decorate() 0 6 1
1
<?php
2
3
/**
4
 * ServiceIdDecorator.php
5
 *
6
 * @author Dominik Kocuj
7
 * @license https://opensource.org/licenses/MIT The MIT License
8
 * @copyright Copyright (c) 2017-2018 kocuj.pl
9
 */
10
11
namespace Kocuj\Di\ServiceIdDecorator;
12
13
use Kocuj\Di\Tools\Camelizer\CamelizerInterface;
14
15
/**
16
 * Service identifier decorator
17
 *
18
 * @package Kocuj\Di\ServiceIdDecorator
19
 */
20
class ServiceIdDecorator implements ServiceIdDecoratorInterface
21
{
22
    /**
23
     * Camelizer object
24
     *
25
     * @var CamelizerInterface
26
     */
27
    private $camelizer;
28
29
    /**
30
     * Constructor
31
     *
32
     * @param CamelizerInterface $camelizer Camelizer object
33
     * @codeCoverageIgnore
34
     */
35
    public function __construct(CamelizerInterface $camelizer)
36
    {
37
        // remember arguments
38
        $this->camelizer = $camelizer;
39
    }
40
41
    /**
42
     * Decorate identifier
43
     *
44
     * @param string $id Identifier to decorate
45
     * @return string Decorated identifier
46
     * @see \Kocuj\Di\ServiceIdDecorator\ServiceIdDecoratorInterface::decorate()
47
     * @codeCoverageIgnore
48
     */
49
    public function decorate(string $id): string
50
    {
51
        // set decorated identifier
52
        $decoratedId = $this->camelizer->camelize($id);
53
        // exit
54
        return $decoratedId;
55
    }
56
}
57