Test Setup Failed
Push — master ( b3b03e...4eeb1f )
by Php Easy Api
03:35
created

StaticPathRepository::appServiceContainer()   A

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 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Resta\Foundation\PathManager;
4
5
use Resta\Support\Str;
6
use Resta\Support\Utils;
7
use Resta\Url\UrlVersionIdentifier;
8
9
class StaticPathRepository
10
{
11
    /**
12
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
13
     * @return string
14
     */
15
    public function app($app=null)
16
    {
17
        $app=($app===null) ? $this->appDetector() : $app;
0 ignored issues
show
introduced by
The condition $app === null is always true.
Loading history...
18
        return StaticPathModel::appPath().''.DIRECTORY_SEPARATOR.''.Str::slashToBackSlash($app);
19
    }
20
21
    /**
22
     * @return mixed
23
     */
24
    public function autoloadNamespace()
25
    {
26
        return root.''.DIRECTORY_SEPARATOR.''.StaticPathList::$appDefine.''.DIRECTORY_SEPARATOR.''.strtolower(StaticPathList::$autoloadNamespace);
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function appBuilder()
33
    {
34
        return path()->model().''.DIRECTORY_SEPARATOR.''.StaticPathList::$builder;
35
    }
36
37
    /**
38
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
39
     * @return string
40
     */
41
    public function appCall($app=null)
42
    {
43
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$controller;
44
    }
45
46
    /**
47
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
48
     * @return string
49
     */
50
    public function appCommand()
51
    {
52
        return $this->appVersion().''.DIRECTORY_SEPARATOR.''.StaticPathList::$command.'';
53
    }
54
55
    /**
56
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
57
     * @return string
58
     */
59
    public function appConfig($app=null)
60
    {
61
        if(isset(core()->paths['config'])){
62
            return core()->paths['config'];
63
        }
64
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$config;
65
    }
66
67
    /**
68
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
69
     * @return string
70
     */
71
    public function appHelpers($app=null)
72
    {
73
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$helpers;
74
    }
75
76
    /**
77
     * @return string
78
     */
79
    public function appTests()
80
    {
81
        return $this->app().''.DIRECTORY_SEPARATOR.''.StaticPathList::$test;
82
    }
83
84
    /**
85
     * @return string
86
     */
87
    public function appWorkers()
88
    {
89
        return  $this->appVersion(null).''.DIRECTORY_SEPARATOR.''.StaticPathList::$workers;
90
    }
91
92
    /**
93
     * @return null|string
94
     */
95
    private function appDetector()
96
    {
97
        return (defined('app')) ? app : null;
98
    }
99
100
    /**
101
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
102
     * @return mixed
103
     */
104
    public function appFactory($app=null)
105
    {
106
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$factory;
107
    }
108
109
    /**
110
     * @return mixed|string
111
     */
112
    public function appKernel()
113
    {
114
        $kernel     = $this->app().''.DIRECTORY_SEPARATOR.''.StaticPathList::$kernel;
115
116
        return $kernel;
117
    }
118
119
    /**
120
     * @return mixed|string
121
     */
122
    public function appProvider()
123
    {
124
        $kernel     = $this->app().''.DIRECTORY_SEPARATOR.''.StaticPathList::$kernel.''.DIRECTORY_SEPARATOR.''.StaticPathList::$provider;
125
126
        return $kernel;
127
    }
128
129
    /**
130
     * @return string
131
     */
132
    public function appLanguage()
133
    {
134
        return self::appStorage().''.DIRECTORY_SEPARATOR.''.StaticPathList::$language;
0 ignored issues
show
Bug Best Practice introduced by
The method Resta\Foundation\PathMan...epository::appStorage() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

134
        return self::/** @scrutinizer ignore-call */ appStorage().''.DIRECTORY_SEPARATOR.''.StaticPathList::$language;
Loading history...
135
    }
136
137
    /**
138
     * @return string
139
     */
140
    public function appLog()
141
    {
142
        return self::appStorage().''.DIRECTORY_SEPARATOR.''.StaticPathList::$log;
0 ignored issues
show
Bug Best Practice introduced by
The method Resta\Foundation\PathMan...epository::appStorage() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

142
        return self::/** @scrutinizer ignore-call */ appStorage().''.DIRECTORY_SEPARATOR.''.StaticPathList::$log;
Loading history...
143
    }
144
145
    /**
146
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
147
     * @return mixed
148
     */
149
    public function appLogger($app=null)
150
    {
151
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.'ServiceLogManager';
152
    }
153
154
    /**
155
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
156
     * @return mixed
157
     */
158
    public function appMiddleware($app=null)
159
    {
160
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$middleware;
161
    }
162
163
    /**
164
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
165
     * @return mixed
166
     */
167
    public function appMigration($app=null)
168
    {
169
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$migration;
170
    }
171
172
    /**
173
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
174
     * @return mixed
175
     */
176
    public function appModel($app=null)
177
    {
178
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$model;
179
    }
180
181
    /**
182
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
183
     * @return mixed
184
     */
185
    public function appException($app=null)
186
    {
187
        return $this->appVersion().''.DIRECTORY_SEPARATOR.''.StaticPathList::$exception;
188
    }
189
190
    /**
191
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
192
     * @return mixed
193
     */
194
    public function appOptionalEvents($app=null)
195
    {
196
        return $this->appVersion().''.DIRECTORY_SEPARATOR.''.StaticPathList::$events;
197
    }
198
199
    /**
200
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
201
     * @return mixed
202
     */
203
    public function appOptionalJob($app=null)
204
    {
205
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$optional.''.DIRECTORY_SEPARATOR.''.StaticPathList::$job;
206
    }
207
208
    /**
209
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
210
     * @return mixed
211
     */
212
    public function appOptionalListeners($app=null)
213
    {
214
        return $this->appVersion().''.DIRECTORY_SEPARATOR.''.StaticPathList::$listeners;
215
    }
216
217
    /**
218
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
219
     * @return mixed
220
     */
221
    public function appOptionalSubscribers($app=null)
222
    {
223
        return $this->appVersion().''.DIRECTORY_SEPARATOR.''.StaticPathList::$listeners.''.DIRECTORY_SEPARATOR.''.StaticPathList::$subscribers;
224
    }
225
226
    /**
227
     * @return mixed
228
     */
229
    public function appRequest()
230
    {
231
        return $this->appVersion().''.DIRECTORY_SEPARATOR.''.StaticPathList::$request;
232
    }
233
234
    /**
235
     * @return mixed
236
     */
237
    public function appRepository()
238
    {
239
        $repository     = $this->app().''.DIRECTORY_SEPARATOR.''.StaticPathList::$repository;
240
241
        return $repository;
242
    }
243
244
    /**
245
     * @return mixed
246
     */
247
    public function appRoute()
248
    {
249
        return $this->appVersion().''.DIRECTORY_SEPARATOR.''.StaticPathList::$route;
250
    }
251
252
    /**
253
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
254
     * @return mixed
255
     */
256
    public function appOptionalSource($app=null)
257
    {
258
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$optional.''.DIRECTORY_SEPARATOR.''.StaticPathList::$sourcePath;
259
    }
260
261
    /**
262
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
263
     * @return mixed
264
     */
265
    public function appOptionalWebservice($app=null)
266
    {
267
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$optional.''.DIRECTORY_SEPARATOR.''.StaticPathList::$webservice;
268
    }
269
270
    /**
271
     * @return mixed
272
     */
273
    public function appResourche()
274
    {
275
        return self::appStorage().''.DIRECTORY_SEPARATOR.''.StaticPathList::$resource;
0 ignored issues
show
Bug Best Practice introduced by
The method Resta\Foundation\PathMan...epository::appStorage() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

275
        return self::/** @scrutinizer ignore-call */ appStorage().''.DIRECTORY_SEPARATOR.''.StaticPathList::$resource;
Loading history...
276
    }
277
278
    /**
279
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
280
     * @return mixed
281
     */
282
    public function appServiceAnnotations($app=null)
283
    {
284
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$serviceAnnotations;
285
    }
286
287
    /**
288
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
289
     * @return mixed
290
     */
291
    public function appServiceContainer($app=null)
292
    {
293
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.'ServiceContainerController';
294
    }
295
296
    /**
297
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
298
     * @return mixed
299
     */
300
    public function appServiceEventDispatcher($app=null)
301
    {
302
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.'ServiceEventDispatcherManager';
303
    }
304
305
    /**
306
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
307
     * @return mixed
308
     */
309
    public function appServiceMiddleware($app=null)
310
    {
311
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$serviceMiddleware;
312
    }
313
314
    /**
315
     * @return mixed
316
     */
317
    public function appStorage()
318
    {
319
        $storage = $this->app().''.DIRECTORY_SEPARATOR.''.StaticPathList::$storage;
320
321
        return $storage;
322
    }
323
324
    /**
325
     * @return mixed
326
     */
327
    public function appStubs()
328
    {
329
        return $this->appKernel().''.DIRECTORY_SEPARATOR.''.StaticPathList::$stub;
330
    }
331
332
    /**
333
     * @param null $app
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $app is correct as it would always require null to be passed?
Loading history...
334
     * @return mixed
335
     */
336
    public function appVersion($app=null)
337
    {
338
        if(defined('app')){
339
340
            $prefixGroup = Str::slashToBackSlash(StaticPathList::$projectPrefixGroup);
341
342
            $app = $this->app($app).''.DIRECTORY_SEPARATOR.''.$prefixGroup.''.DIRECTORY_SEPARATOR.''.UrlVersionIdentifier::version();
343
344
            return $app;
345
346
        }
347
        return null;
348
    }
349
350
    /**
351
     * @return string
352
     */
353
    public function bootDir()
354
    {
355
        //get boot directory for application
356
        return root.''.DIRECTORY_SEPARATOR.''.StaticPathList::$appDefine.''.DIRECTORY_SEPARATOR.''.strtolower(StaticPathList::$boot);
357
    }
358
359
    /**
360
     * @return string
361
     */
362
    public function storeConfigDir()
363
    {
364
        //get store config directory for application
365
        return $this->storeDir().'/Config';
366
    }
367
368
    /**
369
     * @return string
370
     */
371
    public function storeDir()
372
    {
373
        //get store directory for application
374
        return root.''.DIRECTORY_SEPARATOR.''.StaticPathList::$appDefine.''.DIRECTORY_SEPARATOR.''.strtolower(StaticPathList::$store);
375
    }
376
377
    /**
378
     * @param null $controller
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $controller is correct as it would always require null to be passed?
Loading history...
379
     * @param bool $bool
380
     * @return mixed
381
     */
382
    public function controller($controller=null,$bool=false)
383
    {
384
        $namespaceController = ($controller===null) ? app()->namespace()->controller()
0 ignored issues
show
introduced by
The condition $controller === null is always true.
Loading history...
385
            : app()->namespace()->controller($controller,true);
386
387
        if($bool){
388
            $namespaceControllerExplode = explode("\\",$namespaceController);
389
            array_pop($namespaceControllerExplode);
390
391
            $namespaceController = implode("\\",$namespaceControllerExplode);
392
        }
393
394
        return Utils::getPathFromNamespace($namespaceController,false);
395
    }
396
397
    /**
398
     * @return mixed
399
     */
400
    public function encrypterFile()
401
    {
402
        return StaticPathModel::getEncrypter();
403
    }
404
405
    /**
406
     * @return mixed
407
     */
408
    public function environmentFile()
409
    {
410
        return StaticPathModel::getEnvironmentFile();
411
    }
412
413
    /**
414
     * @param $name
415
     * @param $arg
416
     * @return mixed
417
     */
418
    public function __call($name,$arg)
419
    {
420
        $appCall='app'.ucfirst($name);
421
        return $this->{$appCall}();
422
    }
423
424
}