Passed
Push — master ( 2d7f00...8a3a32 )
by Php Easy Api
02:57
created

StaticPathRepository::appException()   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
        if(isset(core()->paths['config'])){
74
            return core()->paths['config'];
75
        }
76
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$helpers;
77
    }
78
79
    /**
80
     * @return null|string
81
     */
82
    private function appDetector()
83
    {
84
        return (defined('app')) ? app : null;
85
    }
86
87
    /**
88
     * @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...
89
     * @return mixed
90
     */
91
    public function appFactory($app=null)
92
    {
93
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$factory;
94
    }
95
96
    /**
97
     * @return mixed|string
98
     */
99
    public function appKernel()
100
    {
101
        $kernel     = $this->app().''.DIRECTORY_SEPARATOR.''.StaticPathList::$kernel;
102
103
        return $kernel;
104
    }
105
106
    /**
107
     * @return mixed|string
108
     */
109
    public function appProvider()
110
    {
111
        $kernel     = $this->app().''.DIRECTORY_SEPARATOR.''.StaticPathList::$kernel.''.DIRECTORY_SEPARATOR.''.StaticPathList::$provider;
112
113
        return $kernel;
114
    }
115
116
    /**
117
     * @return string
118
     */
119
    public function appLanguage()
120
    {
121
        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

121
        return self::/** @scrutinizer ignore-call */ appStorage().''.DIRECTORY_SEPARATOR.''.StaticPathList::$language;
Loading history...
122
    }
123
124
    /**
125
     * @return string
126
     */
127
    public function appLog()
128
    {
129
        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

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

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