_Controller::getView()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: afshin
5
 * Date: 11/10/17
6
 * Time: 3:13 PM
7
 */
8
9
namespace Core\Interfaces;
10
11
use Psr\Container\ContainerInterface;
12
use Psr\Http\Message\ResponseInterface;
13
use Psr\Http\Message\ServerRequestInterface as Request;
14
use Psr\Http\Message\ResponseInterface as Response;
15
use Slim\Views\Blade;
16
17
abstract class _Controller
18
{
19
    protected $container;
20
21
    function __construct(ContainerInterface $container)
22
    {
23
        $this->container = $container;
24
    }
25
26
    public function __get($property)
27
    {
28
        if ($this->container->{$property}) {
29
            return $this->container->{$property};
30
        }
31
    }
32
33
34
35
36
    /**
37
     * Get Slim Container
38
     *
39
     * @return ContainerInterface
40
     */
41
    protected function getContainer()
42
    {
43
        return $this->container;
44
    }
45
    /**
46
     * Get Service From Container
47
     *
48
     * @param string $service
49
     * @return mixed
50
     */
51
    protected function getService($service)
52
    {
53
        return $this->container->{$service};
54
    }
55
    /**
56
     * Get Request
57
     *
58
     * @return Request
59
     */
60
    protected function getRequest()
61
    {
62
        return $this->container->request;
0 ignored issues
show
Bug introduced by
Accessing request on the interface Psr\Container\ContainerInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
63
    }
64
    /**
65
     * Get Response
66
     *
67
     * @return Response
68
     */
69
    protected function getResponse()
70
    {
71
        return $this->container->response;
0 ignored issues
show
Bug introduced by
Accessing response on the interface Psr\Container\ContainerInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
72
    }
73
    /**
74
     * Get Twig Engine
75
     *
76
     * @return Blade
77
     */
78
    protected function getView()
79
    {
80
        return $this->container->view;
0 ignored issues
show
Bug introduced by
Accessing view on the interface Psr\Container\ContainerInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
81
    }
82
    /**
83
     * Render view
84
     *
85
     * @param string $template
86
     * @param array $data
87
     * @return ResponseInterface
88
     */
89
    protected function render($template, $data = [])
90
    {
91
        return $this->getView()->render($this->getResponse(), $template, $data);
92
    }
93
94
95
}