Passed
Pull Request — master (#190)
by Arman
02:54
created

Renderer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __call() 0 7 2
A getAdapter() 0 3 1
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.9.5
13
 */
14
15
namespace Quantum\Renderer;
16
17
use Quantum\Renderer\Contracts\TemplateRendererInterface;
18
use Quantum\Renderer\Exceptions\RendererException;
19
use Quantum\Exceptions\BaseException;
20
21
/**
22
 * Class Renderer
23
 * @package Quantum\Renderer
24
 * @method string render(string $view, array $params = [])
25
 */
26
class Renderer
27
{
28
29
    /**
30
     * @var TemplateRendererInterface
31
     */
32
    private $adapter;
33
34
    /**
35
     * @param TemplateRendererInterface $adapter
36
     */
37
    public function __construct(TemplateRendererInterface $adapter)
38
    {
39
        $this->adapter = $adapter;
40
    }
41
42
    /**
43
     * @return TemplateRendererInterface
44
     */
45
    public function getAdapter(): TemplateRendererInterface
46
    {
47
        return $this->adapter;
48
    }
49
50
    /**
51
     * @param string $method
52
     * @param array|null $arguments
53
     * @return mixed
54
     * @throws BaseException
55
     */
56
    public function __call(string $method, ?array $arguments)
57
    {
58
        if (!method_exists($this->adapter, $method)) {
59
            throw RendererException::methodNotSupported($method, get_class($this->adapter));
60
        }
61
62
        return $this->adapter->$method(...$arguments);
63
    }
64
}