StaticPathRepository::__call()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
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 string
94
     */
95
    public function appSchedule()
96
    {
97
        return  $this->appVersion(null).''.DIRECTORY_SEPARATOR.''.StaticPathList::$schedule;
98
    }
99
100
    /**
101
     * @return null|string
102
     */
103
    private function appDetector()
104
    {
105
        return (defined('app')) ? app : null;
106
    }
107
108
    /**
109
     * @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...
110
     * @return mixed
111
     */
112
    public function appFactory($app=null)
113
    {
114
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$factory;
115
    }
116
117
    /**
118
     * @return mixed|string
119
     */
120
    public function appKernel()
121
    {
122
        $kernel     = $this->app().''.DIRECTORY_SEPARATOR.''.StaticPathList::$kernel;
123
124
        return $kernel;
125
    }
126
127
    /**
128
     * @return mixed|string
129
     */
130
    public function appProvider()
131
    {
132
        $kernel     = $this->app().''.DIRECTORY_SEPARATOR.''.StaticPathList::$kernel.''.DIRECTORY_SEPARATOR.''.StaticPathList::$provider;
133
134
        return $kernel;
135
    }
136
137
    /**
138
     * @return string
139
     */
140
    public function appLanguage()
141
    {
142
        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

142
        return self::/** @scrutinizer ignore-call */ appStorage().''.DIRECTORY_SEPARATOR.''.StaticPathList::$language;
Loading history...
143
    }
144
145
    /**
146
     * @return string
147
     */
148
    public function appLog()
149
    {
150
        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

150
        return self::/** @scrutinizer ignore-call */ appStorage().''.DIRECTORY_SEPARATOR.''.StaticPathList::$log;
Loading history...
151
    }
152
153
    /**
154
     * @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...
155
     * @return mixed
156
     */
157
    public function appLogger($app=null)
158
    {
159
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.'ServiceLogManager';
160
    }
161
162
    /**
163
     * @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...
164
     * @return mixed
165
     */
166
    public function appMiddleware($app=null)
167
    {
168
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$middleware;
169
    }
170
171
    /**
172
     * @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...
173
     * @return mixed
174
     */
175
    public function appMigration($app=null)
176
    {
177
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$migration;
178
    }
179
180
    /**
181
     * @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...
182
     * @return mixed
183
     */
184
    public function appModel($app=null)
185
    {
186
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$model;
187
    }
188
189
    /**
190
     * @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...
191
     * @return mixed
192
     */
193
    public function appException($app=null)
194
    {
195
        return $this->appVersion().''.DIRECTORY_SEPARATOR.''.StaticPathList::$exception;
196
    }
197
198
    /**
199
     * @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...
200
     * @return mixed
201
     */
202
    public function appOptionalEvents($app=null)
203
    {
204
        return $this->appVersion().''.DIRECTORY_SEPARATOR.''.StaticPathList::$events;
205
    }
206
207
    /**
208
     * @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...
209
     * @return mixed
210
     */
211
    public function appOptionalJob($app=null)
212
    {
213
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$optional.''.DIRECTORY_SEPARATOR.''.StaticPathList::$job;
214
    }
215
216
    /**
217
     * @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...
218
     * @return mixed
219
     */
220
    public function appOptionalListeners($app=null)
221
    {
222
        return $this->appVersion().''.DIRECTORY_SEPARATOR.''.StaticPathList::$listeners;
223
    }
224
225
    /**
226
     * @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...
227
     * @return mixed
228
     */
229
    public function appOptionalSubscribers($app=null)
230
    {
231
        return $this->appVersion().''.DIRECTORY_SEPARATOR.''.StaticPathList::$listeners.''.DIRECTORY_SEPARATOR.''.StaticPathList::$subscribers;
232
    }
233
234
    /**
235
     * @return mixed
236
     */
237
    public function appRequest()
238
    {
239
        return $this->appVersion().''.DIRECTORY_SEPARATOR.''.StaticPathList::$request;
240
    }
241
242
    /**
243
     * @return mixed
244
     */
245
    public function appRepository()
246
    {
247
        $repository     = $this->app().''.DIRECTORY_SEPARATOR.''.StaticPathList::$repository;
248
249
        return $repository;
250
    }
251
252
    /**
253
     * @return mixed
254
     */
255
    public function appRoute()
256
    {
257
        return $this->appVersion().''.DIRECTORY_SEPARATOR.''.StaticPathList::$route;
258
    }
259
260
    /**
261
     * @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...
262
     * @return mixed
263
     */
264
    public function appOptionalSource($app=null)
265
    {
266
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$optional.''.DIRECTORY_SEPARATOR.''.StaticPathList::$sourcePath;
267
    }
268
269
    /**
270
     * @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...
271
     * @return mixed
272
     */
273
    public function appOptionalWebservice($app=null)
274
    {
275
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$optional.''.DIRECTORY_SEPARATOR.''.StaticPathList::$webservice;
276
    }
277
278
    /**
279
     * @return mixed
280
     */
281
    public function appResourche()
282
    {
283
        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

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