Passed
Branch master (95f661)
by Php Easy Api
05:36 queued 02:37
created

StaticPathRepository::appTests()   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
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
     * @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...
78
     * @return string
79
     */
80
    public function appTests($app=null)
81
    {
82
        $tests     = $this->app().''.DIRECTORY_SEPARATOR.''.StaticPathList::$test;
83
84
        return $tests;
85
    }
86
87
    /**
88
     * @return null|string
89
     */
90
    private function appDetector()
91
    {
92
        return (defined('app')) ? app : null;
93
    }
94
95
    /**
96
     * @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...
97
     * @return mixed
98
     */
99
    public function appFactory($app=null)
100
    {
101
        return $this->appVersion($app).''.DIRECTORY_SEPARATOR.''.StaticPathList::$factory;
102
    }
103
104
    /**
105
     * @return mixed|string
106
     */
107
    public function appKernel()
108
    {
109
        $kernel     = $this->app().''.DIRECTORY_SEPARATOR.''.StaticPathList::$kernel;
110
111
        return $kernel;
112
    }
113
114
    /**
115
     * @return mixed|string
116
     */
117
    public function appProvider()
118
    {
119
        $kernel     = $this->app().''.DIRECTORY_SEPARATOR.''.StaticPathList::$kernel.''.DIRECTORY_SEPARATOR.''.StaticPathList::$provider;
120
121
        return $kernel;
122
    }
123
124
    /**
125
     * @return string
126
     */
127
    public function appLanguage()
128
    {
129
        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

129
        return self::/** @scrutinizer ignore-call */ appStorage().''.DIRECTORY_SEPARATOR.''.StaticPathList::$language;
Loading history...
130
    }
131
132
    /**
133
     * @return string
134
     */
135
    public function appLog()
136
    {
137
        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

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

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