ContainerBase::getView()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: famoser
5
 * Date: 03/12/2016
6
 * Time: 20:56
7
 */
8
9
namespace Famoser\XKCDCache\Framework;
10
11
12
use Famoser\XKCDCache\Services\Interfaces\CacheServiceInterface;
13
use Famoser\XKCDCache\Services\Interfaces\DatabaseServiceInterface;
14
use Famoser\XKCDCache\Services\Interfaces\LoggingServiceInterface;
15
use Famoser\XKCDCache\Services\Interfaces\SettingServiceInterface;
16
use Famoser\XKCDCache\Services\Interfaces\XKCDServiceInterface;
17
use Interop\Container\ContainerInterface;
18
use Slim\Interfaces\RouterInterface;
19
20
/**
21
 * resolves the classes distributed by the ContainerInterface
22
 *
23
 * @package Famoser\XKCDCache\Framework
24
 */
25
class ContainerBase
26
{
27
    const DATABASE_SERVICE_KEY = 'databaseService';
28
    const LOGGING_SERVICE_KEY = 'loggingService';
29
    const CACHE_SERVICE_KEY = 'cacheService';
30
    const XKCD_SERVICE_KEY = 'xkcdService';
31
    const SETTING_SERVICE_KEY = 'settingService';
32
33
    /* @var ContainerInterface $container */
34
    private $container;
35
36
    /**
37
     * RequestService constructor.
38
     *
39
     * @param ContainerInterface $container
40
     */
41 19
    public function __construct(ContainerInterface $container)
42
    {
43 19
        $this->container = $container;
44 19
    }
45
46
    /**
47
     * get database helper, used for database access
48
     *
49
     * @return DatabaseServiceInterface
50
     */
51 19
    public function getDatabaseService()
52
    {
53 19
        return $this->container->get(static::DATABASE_SERVICE_KEY);
54
    }
55
56
    /**
57
     * return the logging service
58
     *
59
     * @return LoggingServiceInterface
60
     */
61 6
    public function getLoggingService()
62
    {
63 6
        return $this->container->get(static::LOGGING_SERVICE_KEY);
64
    }
65
66
    /**
67
     * get database helper, used for database access
68
     *
69
     * @return CacheServiceInterface
70
     */
71 5
    public function getCacheService()
72
    {
73 5
        return $this->container->get(static::CACHE_SERVICE_KEY);
74
    }
75
76
    /**
77
     * get database helper, used for database access
78
     *
79
     * @return XKCDServiceInterface
80
     */
81 5
    public function getXKCDService()
82
    {
83 5
        return $this->container->get(static::XKCD_SERVICE_KEY);
84
    }
85
86
    /**
87
     * get a service which allows access to settings
88
     *
89
     * @return SettingServiceInterface
90
     */
91 19
    public function getSettingService()
92
    {
93 19
        return $this->container->get(static::SETTING_SERVICE_KEY);
94
    }
95
96
    /**
97
     * get router
98
     *
99
     * @return RouterInterface
100
     */
101 1
    public function getRouter()
102
    {
103 1
        return $this->container->get('router');
104
    }
105
106
    /**
107
     * get the view
108
     *
109
     * @return mixed
110
     */
111 7
    public function getView()
112
    {
113 7
        return $this->container->get('view');
114
    }
115
}