PhpFileRenderer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A invoke() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of PhpUnitGen.
5
 *
6
 * (c) 2017-2018 Paul Thébaud <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PhpUnitGen\Renderer;
13
14
use PhpUnitGen\Configuration\ConfigurationInterface\ConfigInterface;
15
use PhpUnitGen\Model\ModelInterface\PhpFileModelInterface;
16
use PhpUnitGen\Renderer\Helper\ParametersHelper;
17
use PhpUnitGen\Renderer\Helper\ValueHelper;
18
use PhpUnitGen\Renderer\RendererInterface\PhpFileRendererInterface;
19
use Slim\Views\PhpRenderer;
20
21
/**
22
 * Class PhpFileRenderer.
23
 *
24
 * @author     Paul Thébaud <[email protected]>.
25
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
26
 * @license    https://opensource.org/licenses/MIT The MIT license.
27
 * @link       https://github.com/paul-thebaud/phpunit-generator
28
 * @since      Class available since Release 2.0.0.
29
 */
30
class PhpFileRenderer implements PhpFileRendererInterface
31
{
32
    /**
33
     * @var PhpRenderer $renderer The twig renderer.
34
     */
35
    protected $renderer;
36
37
    /**
38
     * AbstractRender constructor.
39
     *
40
     * @param ConfigInterface $config   The configuration.
41
     * @param PhpRenderer     $renderer The php renderer.
42
     */
43
    public function __construct(
44
        ConfigInterface $config,
45
        PhpRenderer $renderer
46
    ) {
47
        $this->renderer = $renderer;
48
        $this->renderer->addAttribute('config', $config);
49
        $this->renderer->addAttribute('parametersHelper', new ParametersHelper());
50
        $this->renderer->addAttribute('valueHelper', new ValueHelper());
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function invoke(PhpFileModelInterface $phpFile): string
57
    {
58
        return $this->renderer->fetch('class.php', [
59
            'phpFile' => $phpFile
60
        ]);
61
    }
62
}
63