Passed
Push — master ( dd091e...934657 )
by 世昌
02:26
created

Context::setApplication()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
namespace nebula;
3
4
use nebula\application\Route;
5
use nebula\component\debug\Debug;
6
use nebula\application\Application;
7
use nebula\component\loader\Loader;
8
use nebula\application\config\Config;
9
use nebula\component\request\Request;
10
use nebula\component\cacheable\CacheInterface;
11
12
/**
13
 * 应用
14
 *
15
 */
16
class Context
17
{
18
    /**
19
     * 应用路径
20
     *
21
     * @var string
22
     */
23
    protected $path;
24
25
    /**
26
     * 数据路径
27
     *
28
     * @var string
29
     */
30
    protected $dataPath;
31
32
    /**
33
     * 类加载器
34
     *
35
     * @var Loader
36
     */
37
    protected $classLoader;
38
39
    /**
40
     * 调试工具
41
     *
42
     * @var Debug
43
     */
44
    protected $debugger;
45
46
    /**
47
     * 路由
48
     *
49
     * @var Route
50
     */
51
    protected $route;
52
    
53
    /**
54
     * 配置信息
55
     *
56
     * @var Config
57
     */
58
    protected $config;
59
60
    /**
61
     * 应用引用程序
62
     *
63
     * @var Application
64
     */
65
    protected $application;
66
67
    /**
68
     * 请求封装
69
     *
70
     * @var Request
71
     */
72
    protected $request;
73
74
    /**
75
     * 缓存
76
     *
77
     * @var CacheInterface
78
     */
79
    protected $cache;
80
    
81
    /**
82
     * 静态实例
83
     *
84
     * @var self
85
     */
86
    protected static $instance;
87
88
89
    /**
90
     * 返回实例
91
     *
92
     * @return self
93
     */
94
    public static function instance()
95
    {
96
        if (isset(static::$instance)) {
97
            return static::$instance;
98
        }
99
        return static::$instance = new static;
100
    }
101
    
102
    /**
103
     * Get 类加载器
104
     *
105
     * @return  Loader
106
     */
107
    public function getClassLoader()
108
    {
109
        return $this->classLoader;
110
    }
111
112
    /**
113
     * Set 类加载器
114
     *
115
     * @param  Loader  $classLoader  类加载器
116
     *
117
     * @return  self
118
     */
119
    public function setClassLoader(Loader $classLoader)
120
    {
121
        $this->classLoader = $classLoader;
122
123
        return $this;
124
    }
125
126
    /**
127
     * Get 调试工具
128
     *
129
     * @return  Debug
130
     */
131
    public function getDebugger()
132
    {
133
        return $this->debugger;
134
    }
135
136
    /**
137
     * Set 调试工具
138
     *
139
     * @param  Debug  $debugger  调试工具
140
     *
141
     * @return  self
142
     */
143
    public function setDebugger(Debug $debugger)
144
    {
145
        $this->debugger = $debugger;
146
147
        return $this;
148
    }
149
150
151
    /**
152
     * Get 配置信息
153
     *
154
     * @return  Config
155
     */
156
    public function getConfig()
157
    {
158
        return $this->config;
159
    }
160
161
    /**
162
     * Set 配置信息
163
     *
164
     * @param  Config  $config  配置信息
165
     *
166
     * @return  self
167
     */
168
    public function setConfig(Config $config)
169
    {
170
        $this->config = $config;
171
172
        return $this;
173
    }
174
175
    /**
176
     * Get 路由
177
     *
178
     * @return  Route
179
     */
180
    public function getRoute()
181
    {
182
        return $this->route;
183
    }
184
185
    /**
186
     * Set 路由
187
     *
188
     * @param  Route  $route  路由
189
     *
190
     * @return  self
191
     */
192
    public function setRoute(Route $route)
193
    {
194
        $this->route = $route;
195
196
        return $this;
197
    }
198
 
199
200
    /**
201
     * Get 应用引用程序
202
     *
203
     * @return  Application
204
     */
205
    public function getApplication()
206
    {
207
        return $this->application;
208
    }
209
210
    /**
211
     * Set 应用引用程序
212
     *
213
     * @param  Application  $application  应用引用程序
214
     *
215
     * @return  self
216
     */
217
    public function setApplication(Application $application)
218
    {
219
        $this->application = $application;
220
221
        return $this;
222
    }
223
224
    /**
225
     * Get 请求封装
226
     *
227
     * @return  Request
228
     */
229
    public function getRequest()
230
    {
231
        return $this->request;
232
    }
233
234
    /**
235
     * Set 请求封装
236
     *
237
     * @param  Request  $request  请求封装
238
     *
239
     * @return  self
240
     */
241
    public function setRequest(Request $request)
242
    {
243
        $this->request = $request;
244
245
        return $this;
246
    }
247
248
    /**
249
     * Get 缓存
250
     *
251
     * @return  CacheInterface
252
     */ 
253
    public function getCache()
254
    {
255
        return $this->cache;
256
    }
257
258
    /**
259
     * Set 缓存
260
     *
261
     * @param  CacheInterface  $cache  缓存
262
     *
263
     * @return  self
264
     */ 
265
    public function setCache(CacheInterface $cache)
266
    {
267
        $this->cache = $cache;
268
269
        return $this;
270
    }
271
}
272