Passed
Push — master ( 41e10c...0c10bb )
by Alexander
03:14
created

logs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 3
rs 10
1
<?php 
2
3
/**
4
 * Lenevor Framework
5
 *
6
 * LICENSE
7
 *
8
 * This source file is subject to the new BSD license that is bundled
9
 * with this package in the file license.md.
10
 * It is also available through the world-wide-web at this URL:
11
 * https://lenevor.com/license
12
 * If you did not receive a copy of the license and are unable to
13
 * obtain it through the world-wide-web, please send an email
14
 * to [email protected] so we can send you a copy immediately.
15
 *
16
 * @package     Lenevor
17
 * @subpackage  Base
18
 * @link        https://lenevor.com
19
 * @copyright   Copyright (c) 2019 - 2023 Alexander Campo <[email protected]>
20
 * @license     https://opensource.org/licenses/BSD-3-Clause New BSD license or see https://lenevor.com/license or see /license.md
21
 */
22
23
use Syscodes\Components\Http\Response;
24
use Syscodes\Components\Core\Application;
25
use Syscodes\Components\Support\WebString;
26
use Syscodes\Components\Support\Facades\Date;
27
use Syscodes\Components\Contracts\View\Factory;
28
use Syscodes\Components\Routing\Supported\UrlGenerator;
0 ignored issues
show
Bug introduced by
The type Syscodes\Components\Routing\Supported\UrlGenerator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
29
use Syscodes\Components\Contracts\Routing\RouteResponse;
30
use Syscodes\Components\Contracts\Debug\ExceptionHandler;
31
use Syscodes\Bundles\WebResourceBundle\Autoloader\Autoload;
32
use Syscodes\Bundles\WebResourceBundle\Autoloader\Autoloader;
33
use Syscodes\Components\Http\Exceptions\HttpResponseException;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, HttpResponseException. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
34
use Syscodes\Components\Contracts\Auth\Factory as AuthFactory;
35
use Syscodes\Components\Contracts\Cookie\Factory as CookieFactory;
36
37
if ( ! function_exists('abort')) {
38
    /**
39
     * Throw an HttpException with the given data.
40
     *
41
     * @param  \Syscodes\Components\Http\Response|int  $code
42
     * @param  string  $message
43
     * @param  array  $headers
44
     * 
45
     * @return void
46
     *
47
     * @throws \Syscodes\Components\Core\Http\Exceptions\HttpException
48
     * @throws \Syscodes\Components\Core\Http\Exceptions\LenevorException
49
     */
50
    function abort(int $code, string $message = '', array $headers = [])
51
    {
52
        if ($code instanceof Response) {
0 ignored issues
show
introduced by
$code is never a sub-type of Syscodes\Components\Http\Response.
Loading history...
53
            throw new HttpResponseException($code);
54
        }
55
        return app()->abort($code, $message, $headers);
56
    }
57
}
58
59
if ( ! function_exists('about_if')) {
60
    /**
61
     * Throw an HttpException with the given data if the given condition is true.
62
     * 
63
     * @param  bool  $boolean
64
     * @param  \Syscodes\Components\Http\Response|int  $code
65
     * @param  string  $message
66
     * @param  array  $headers
67
     * 
68
     * @return void
69
     * @throws \Syscodes\Components\Core\Http\Exceptions\HttpException
70
     * @throws \Syscodes\Components\Core\Http\Exceptions\LenevorException
71
     */
72
    function about_if($boolean, int $code, string $message = '', array $headers = [])
73
    {
74
        if ($boolean) {
75
            abort($code, $message, $headers);
76
        }
77
    }
78
}
79
80
if ( ! function_exists('abort_unless')) {
81
    /**
82
     * Throw an HttpException with the given data unless the given condition is true.
83
     * 
84
     * @param  bool  $boolean
85
     * @param  \Syscodes\Components\Http\Response|int  $code
86
     * @param  string  $message
87
     * @param  array  $headers
88
     * 
89
     * @return void
90
     * @throws \Syscodes\Components\Core\Http\Exceptions\HttpException
91
     * @throws \Syscodes\Components\Core\Http\Exceptions\LenevorException
92
     */
93
    function abort_unless($boolean, int $code, string $message = '', array $headers = [])
94
    {
95
        if ( ! $boolean) {
96
            abort($code, $message, $headers);
97
        }
98
    }
99
}
100
101
if ( ! function_exists('action')) {
102
    /**
103
     * Generate the URL to a controller action.
104
     * 
105
     * @param  string|array  $name
106
     * @param  mixed  $parameters
107
     * @param  bool  $absolute
108
     * 
109
     * @return string
110
     */
111
    function action($name, $parameters = [], $absolute = true)
112
    {
113
        return app('url')->action($name, $parameters, $absolute);
0 ignored issues
show
Bug introduced by
The method action() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

113
        return app('url')->/** @scrutinizer ignore-call */ action($name, $parameters, $absolute);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
114
    }
115
}
116
117
if ( ! function_exists('app')) {
118
    /**
119
     * Get the available Application instance.
120
     *
121
     * @param  string  $id  
122
     * @param  array  $parameters
123
     * 
124
     * @return mixed|\Syscodes\Components\Contracts\Core\Application
125
     */
126
    function app($id = null, array $parameters = [])
127
    {
128
        if (is_null($id)) {
129
            return Application::getInstance();
130
        }
131
132
        return Application::getInstance()->make($id, $parameters);
133
    }
134
}
135
136
if ( ! function_exists('autoloader')) {
137
    /**
138
     * Get Autoloader class instance with initialized to autoload.
139
     * 
140
     * @return \Syscodes\Bundles\WebResourceBundle\Autoloader\Autoloader
141
     */
142
    function autoloader()
143
    {
144
        return Autoloader::instance()->initialize(new Autoload());
145
    }
146
}
147
148
if ( ! function_exists('appPath')) {
149
    /**
150
     * Get the path to the application folder.
151
     * 
152
     * @param  string  $path
153
     * 
154
     * @return string
155
     */
156
    function appPath($path = '')
157
    {
158
        return app()->path($path);
159
    }
160
}
161
162
if ( ! function_exists('asset')) {
163
    /**
164
     * Generate an asset path for the application.
165
     * 
166
     * @param  string  $path
167
     * @param  bool  $secure  
168
     * 
169
     * @return string
170
     */
171
    function asset($path, $secure = null)
172
    {
173
        return app('url')->asset($path, $secure);
0 ignored issues
show
Bug introduced by
The method asset() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

173
        return app('url')->/** @scrutinizer ignore-call */ asset($path, $secure);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
174
    }
175
}
176
177
if ( ! function_exists('auth')) {
178
    /**
179
     * Get the available auth instance.
180
     * 
181
     * @param  string|null  $guard
182
     * 
183
     * @return \Syscodes\Components\Contracts\Auth\Factory|\Syscodes\Components\Contracts\Auth\Guard|\Syscodes\Components\Contracts\Auth\StateGuard
184
     */
185
    function auth($guard = null)
186
    {
187
        if (is_null($guard)) {
188
            return app(AuthFactory::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return app(Syscodes\Comp...ts\Auth\Factory::class) also could return the type Syscodes\Components\Contracts\Core\Application which is incompatible with the documented return type Syscodes\Components\Cont...ntracts\Auth\StateGuard.
Loading history...
189
        }
190
191
        return app(AuthFactory::class)->guard($guard);
0 ignored issues
show
Bug introduced by
The method guard() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

191
        return app(AuthFactory::class)->/** @scrutinizer ignore-call */ guard($guard);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
192
    }
193
}
194
195
if ( ! function_exists('back')) {
196
    /**
197
     * Create a new redirect response to the previous location.
198
     * 
199
     * @param  int  $status    
200
     * @param  array  $headers
201
     * @param  mixed  $fallback  
202
     * 
203
     * @return \Syscodes\Components\Http\RedirectResponse
204
     */
205
    function back(int $status = 302, array $headers = [], mixed $fallback = false)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
206
    {
207
        return app('redirect')->back($status, $headers, $fallback);
0 ignored issues
show
Bug introduced by
The method back() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

207
        return app('redirect')->/** @scrutinizer ignore-call */ back($status, $headers, $fallback);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
208
    }
209
}
210
211
if ( ! function_exists('basePath')) {
212
    /**
213
     * Get the path to the base of the install.
214
     *
215
     * @param  string  $path
216
     * 
217
     * @return string
218
     */
219
    function basePath($path = '')
220
    {
221
        return app()->basePath($path);
222
    }
223
}
224
225
if ( ! function_exists('bcrypt')) {
226
    /**
227
     * Hash the given value against the bcrypt algorithm.
228
     * 
229
     * @param  string  $value
230
     * @param  array  $options
231
     * 
232
     * @return string
233
     */
234
    function bcrypt($value, $options = [])
235
    {
236
        return app('hash')->driver('bcrypt')->make($value, $options);
0 ignored issues
show
Bug introduced by
The method driver() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

236
        return app('hash')->/** @scrutinizer ignore-call */ driver('bcrypt')->make($value, $options);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
237
    }
238
}
239
240
if ( ! function_exists('cache')) {
241
    /**
242
     * Get / set the specified cache value.
243
     *
244
     * If an array is passed, we'll assume you want to put to the cache.
245
     *
246
     * @param  dynamic  key|key,default|data,expiration|null
0 ignored issues
show
Bug introduced by
The type key was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
247
     * 
248
     * @return mixed|\Syscodes\Components\Cache\CacheManager
249
     *
250
     * @throws \Exception
251
     */
252
    function cache()
253
    {
254
        $arguments = func_get_args();
255
        
256
        if (empty($arguments)) {
257
            return app('cache');
258
        }
259
        
260
        if (is_string($arguments[0])) {
261
            return app('cache')->get(...$arguments);
0 ignored issues
show
Bug introduced by
$arguments is expanded, but the parameter $id of Psr\Container\ContainerInterface::get() does not expect variable arguments. ( Ignorable by Annotation )

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

261
            return app('cache')->get(/** @scrutinizer ignore-type */ ...$arguments);
Loading history...
262
        }
263
        
264
        if ( ! is_array($arguments[0])) {
265
            throw new Exception('When setting a value in the cache, you must pass an array of key / value pairs.');
266
        }
267
        
268
        if ( ! isset($arguments[1])) {
269
            throw new Exception('You must specify an expiration time when setting a value in the cache.');
270
        }
271
        
272
        return app('cache')->put(key($arguments[0]), reset($arguments[0]), $arguments[1]);
0 ignored issues
show
Bug introduced by
The method put() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

272
        return app('cache')->/** @scrutinizer ignore-call */ put(key($arguments[0]), reset($arguments[0]), $arguments[1]);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
273
    }
274
}
275
276
if ( ! function_exists('config')) {
277
    /**
278
     * Get / set the specified configuration value.
279
     * If an array is passed as the key, we will assume you want to set 
280
     * an array of values.
281
     *
282
     * @param   array|string  $key  
283
     * @param   mixed  $default  
284
     *
285
     * @return  mixed|\Syscodes\Components\Config\Configure
286
     */
287
    function config($key = null, mixed $value = null)
288
    {
289
        if ($key === null) {
290
            return app('config');
291
        }
292
293
        if (is_array($key)) {
294
            return app('config')->set($key, $value);
0 ignored issues
show
Bug introduced by
It seems like $value can also be of type null; however, parameter $value of Syscodes\Components\Cont...tainer\Container::set() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

294
            return app('config')->set($key, /** @scrutinizer ignore-type */ $value);
Loading history...
Bug introduced by
$key of type array is incompatible with the type string expected by parameter $id of Syscodes\Components\Cont...tainer\Container::set(). ( Ignorable by Annotation )

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

294
            return app('config')->set(/** @scrutinizer ignore-type */ $key, $value);
Loading history...
295
        }
296
        
297
        return app('config')->get($key, $value);
0 ignored issues
show
Unused Code introduced by
The call to Psr\Container\ContainerInterface::get() has too many arguments starting with $value. ( Ignorable by Annotation )

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

297
        return app('config')->/** @scrutinizer ignore-call */ get($key, $value);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
298
    }
299
}
300
301
if ( ! function_exists('configPath')) {
302
    /**
303
     * Get the path to the configuration folder.
304
     *
305
     * @param  string  $path
306
     * 
307
     * @return string
308
     */
309
    function configPath($path = '')
310
    {
311
        return app()->configPath($path);
312
    }
313
}
314
315
if ( ! function_exists('cookie')) {
316
    /**
317
     * Create a new cookie instance.
318
     *
319
     * @param  string|null  $name
320
     * @param  string|string[]|null  $value
321
     * @param  int  $minutes
322
     * @param  string|null  $path
323
     * @param  string|null  $domain
324
     * @param  bool|null  $secure
325
     * @param  bool  $httpOnly
326
     * @param  bool  $raw
327
     * @param  string|null  $sameSite
328
     * 
329
     * @return \Syscodes\Components\Cookie\CookieManager|\Syscodes\Components\Http\Cookie
330
     */
331
    function cookie(
332
        string $name = null, 
333
        $value = null, 
334
        int $minutes = 0, 
335
        string $path = null, 
336
        string $domain = null, 
337
        bool $secure = null, 
338
        bool $httpOnly = true, 
339
        bool $raw = false, 
340
        string $sameSite = null
341
    ) {
342
        $cookie = app(CookieFactory::class);
343
        
344
        if (is_null($name)) {
345
            return $cookie;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $cookie also could return the type Syscodes\Components\Contracts\Core\Application which is incompatible with the documented return type Syscodes\Components\Cook...\Components\Http\Cookie.
Loading history...
346
        }
347
        
348
        return $cookie->make($name, $value, $minutes, $path, $domain, $secure, $httpOnly, $raw, $sameSite);
0 ignored issues
show
Bug introduced by
It seems like $value can also be of type null and string; however, parameter $parameters of Syscodes\Components\Cont...ainer\Container::make() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

348
        return $cookie->make($name, /** @scrutinizer ignore-type */ $value, $minutes, $path, $domain, $secure, $httpOnly, $raw, $sameSite);
Loading history...
Unused Code introduced by
The call to Syscodes\Components\Cont...ainer\Container::make() has too many arguments starting with $minutes. ( Ignorable by Annotation )

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

348
        return $cookie->/** @scrutinizer ignore-call */ make($name, $value, $minutes, $path, $domain, $secure, $httpOnly, $raw, $sameSite);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
349
    }
350
}
351
352
if ( ! function_exists('csrf_field')) {
353
    /**
354
     * Generate a CSRF token form field.
355
     * 
356
     * @return string
357
     */
358
    function csrf_field()
359
    {
360
        return new WebString('<input type="hidden" name="_token" value="'.csrf_token().'">');
361
    }
362
}
363
364
if ( ! function_exists('csrf_token')) {
365
    /**
366
     * Get the CSRF token value.
367
     * 
368
     * @return string
369
     * 
370
     * @throws \RuntimeException
371
     */
372
    function csrf_token()
373
    {
374
        $session = app('session');
375
        
376
        if (isset($session)) {
377
            return $session->token();
0 ignored issues
show
Bug introduced by
The method token() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

377
            return $session->/** @scrutinizer ignore-call */ token();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
378
        }
379
380
        throw new RuntimeException('Application session store not set');
381
    }
382
}
383
384
if ( ! function_exists('databasePath')) {
385
    /**
386
     * Get the path to the database directory.
387
     * 
388
     * @param  string  $path
389
     * 
390
     * @return string
391
     */
392
    function databasePath($path = '')
393
    {
394
        return app()->databasePath($path);
395
    }
396
}
397
398
if ( ! function_exists('decrypt')) {
399
    /**
400
     * Decrypt the given value.
401
     * 
402
     * @param  mixed  $value
403
     * @param  bool  $unserialize  
404
     * 
405
     * @return string
406
     */
407
    function decrypt($value, bool $unserialize = true)
408
    {
409
        return app('encrypter')->decrypt($value, $unserialize);
0 ignored issues
show
Bug introduced by
The method decrypt() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

409
        return app('encrypter')->/** @scrutinizer ignore-call */ decrypt($value, $unserialize);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
410
    }
411
}
412
413
if ( ! function_exists('e')) {
414
    /**
415
     * Escape HTML entities in a string.
416
     *
417
     * @param  string  $value
418
     *
419
     * @return string
420
     */
421
    function e($value)
422
    {
423
        return htmlentities($value, ENT_QUOTES, 'UTF-8', false);
424
    }
425
}
426
427
if ( ! function_exists('encrypt')) {
428
    /**
429
     * Encrypt the given value.
430
     * 
431
     * @param  mixed  $value
432
     * @param  bool  $serialize  
433
     * 
434
     * @return string
435
     */
436
    function encrypt($value, bool $serialize = true)
437
    {
438
        return app('encrypter')->encrypt($value, $serialize);
0 ignored issues
show
Bug introduced by
The method encrypt() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

438
        return app('encrypter')->/** @scrutinizer ignore-call */ encrypt($value, $serialize);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
439
    }
440
}
441
442
if ( ! function_exists('event')) {
443
    /**
444
     * Dispatch an event and call the listeners.
445
     * 
446
     * @param  string|object  $event
447
     * @param  mixed  $payload
448
     * @param  bool  $halt
449
     * 
450
     * @return array|null
451
     */
452
    function event(...$args) 
453
    {
454
        return app('events')->dispatch(...$args);
0 ignored issues
show
Bug introduced by
The method dispatch() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

454
        return app('events')->/** @scrutinizer ignore-call */ dispatch(...$args);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
455
    }
456
}
457
458
if ( ! function_exists('getClass')) {
459
    /**
460
     * Function to crop the full name of the namespace and leave 
461
     * only the name of the class.
462
     * 
463
     * @param  string|object  $classname
464
     * @param  bool  $bool  
465
     * 
466
     * @return array|string
467
     */
468
    function getClass($classname, bool $bool = false)
469
    {
470
        $position = explode('\\', get_class($classname));
0 ignored issues
show
Bug introduced by
It seems like $classname can also be of type string; however, parameter $object of get_class() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

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

470
        $position = explode('\\', get_class(/** @scrutinizer ignore-type */ $classname));
Loading history...
471
        
472
        return ! $bool ? array_pop($position) : get_class($classname);
473
    }
474
}
475
476
if ( ! function_exists('info')) {
477
    /**
478
     * Write some information to the log.
479
     * 
480
     * @param  string  $message
481
     * @param  array  $context
482
     * 
483
     * @return void
484
     */
485
    function info($message, array $context = [])
486
    {
487
        app('log')->info($message, $context);
0 ignored issues
show
Bug introduced by
The method info() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

487
        app('log')->/** @scrutinizer ignore-call */ info($message, $context);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
488
    }
489
}
490
491
if ( ! function_exists('isCli')) {
492
    /**
493
     * Determines if this request was made from the command line (CLI).
494
     * 
495
     * @return bool
496
     */
497
    function isCli()
498
    {
499
        return (\PHP_SAPI === 'cli' || defined('STDIN') || \PHP_SAPI === 'phpdbg');
500
    }
501
}
502
503
if ( ! function_exists('isGetCommonPath')) {
504
    /**
505
     * Find the common "root" path of two given paths or FQFN's.
506
     * 
507
     * @param  array  $paths  Array with the paths to compare
508
     * 
509
     * @return string  The determined common path section
510
     */
511
    function isGetCommonPath($paths)
512
    {
513
        $lastOffset = 1;
514
        $common     = '/';
515
        
516
        while (($index = strpos($paths[0], '/', $lastOffset)) !== false) {
517
            $dirLen = $index - $lastOffset + 1; // include
518
            $dir = substr($paths[0], $lastOffset, $dirLen);
519
            
520
            foreach ($paths as $path) {
521
                if (substr($path, $lastOffset, $dirLen) != $dir) {
522
                    return $common;
523
                }
524
            }
525
            
526
            $common    .= $dir;
527
            $lastOffset = $index + 1;
528
        }
529
        
530
        return $common;
531
    }
532
}
533
534
if ( ! function_exists('isImport')) {
535
    /**
536
     * Loads in a core class and optionally an app class override if it exists.
537
     * 
538
     * @param  string  $path
539
     * @param  string  $folder
540
     * 
541
     * @return void
542
     */
543
    function isImport($path, $folder = 'classes')
544
    {
545
        $path = str_replace('/', DIRECTORY_SEPARATOR, $path);
546
        
547
        // load it ffrom the core if it exists
548
        if (is_file(SYS_PATH.$folder.DIRECTORY_SEPARATOR.$path.'.php')) {
549
            require_once SYS_PATH.$folder.DIRECTORY_SEPARATOR.$path.'.php';
550
        }
551
        
552
        // if the app has an override (or a non-core file), load that too
553
        if (is_file(APP_PATH.$folder.DIRECTORY_SEPARATOR.$path.'.php')) {
554
            require_once APP_PATH.$folder.DIRECTORY_SEPARATOR.$path.'.php';
555
        }
556
557
        require_once __DIR__.DIRECTORY_SEPARATOR.$folder.'/'.$path.'.php';
558
    }
559
}
560
561
if ( ! function_exists('langPath')) {
562
    /**
563
     * Get the path to the language folder.
564
     *
565
     * @param  string  $path
566
     * 
567
     * @return string
568
     */
569
    function langPath($path = '')
570
    {
571
        return app('path.lang').($path ? DIRECTORY_SEPARATOR.$path : $path);
0 ignored issues
show
Bug introduced by
Are you sure app('path.lang') of type Syscodes\Components\Cont...\Core\Application|mixed can be used in concatenation? ( Ignorable by Annotation )

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

571
        return /** @scrutinizer ignore-type */ app('path.lang').($path ? DIRECTORY_SEPARATOR.$path : $path);
Loading history...
572
    }
573
}
574
575
if ( ! function_exists('logger')) {
576
    /**
577
     * Log a debug message to the logs.
578
     * 
579
     * @param  string|null  $message
580
     * @param  array  $context
581
     * 
582
     * @return \Syscodes\Components\Log\LogManager|null
583
     */
584
    function logger($message = null, array $context = [])
585
    {
586
        if (is_null($message)) {
587
            return app('log');
0 ignored issues
show
Bug Best Practice introduced by
The expression return app('log') also could return the type Syscodes\Components\Contracts\Core\Application which is incompatible with the documented return type Syscodes\Components\Log\LogManager|null.
Loading history...
588
        }
589
        
590
        return app('log')->debug($message, $context);
0 ignored issues
show
Bug introduced by
The method debug() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

590
        return app('log')->/** @scrutinizer ignore-call */ debug($message, $context);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
591
    }
592
}
593
594
if ( ! function_exists('logs')) {
595
    
596
    /**
597
     * Get a log level instance.
598
     * 
599
     * @param  string  $message
600
     * @param  array  $context
601
     * @param  string  $level
602
     * 
603
     * @return \Syscodes\Components\Log\LogManager|\Psr\Log\LoggerInterface
604
     */
605
    function logs($message, array $context = [], $level = 'notice')
606
    {
607
        return app('log')->log($level, $message, $context);
0 ignored issues
show
Bug introduced by
The method log() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

607
        return app('log')->/** @scrutinizer ignore-call */ log($level, $message, $context);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
608
    }
609
}
610
611
if ( ! function_exists('methodField'))
612
{
613
    /**
614
     * Generate a form field to spoof the HTTP verb used by forms.
615
     * 
616
     * @param  string  $method
617
     * 
618
     * @return \Syscodes\Components\Support\WebString
619
     */
620
    function methodField($method)
621
    {
622
        return new WebString('<input type="hidden" name="_method" value="'.$method.'">');
623
    }
624
}
625
626
if ( ! function_exists('now')) {
627
    /**
628
     * Create a new Chronos class instance for the current time.
629
     * 
630
     * @param  \DateTimeZone|string|null  $timezone
631
     * 
632
     * @return \Syscodes\Components\Support\Chronos
633
     */
634
    function now($timezone = null)
635
    {
636
        return Date::now($timezone);
0 ignored issues
show
Bug introduced by
It seems like $timezone can also be of type DateTimeZone; however, parameter $timezone of Syscodes\Components\Support\Facades\Date::now() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

636
        return Date::now(/** @scrutinizer ignore-type */ $timezone);
Loading history...
637
    }
638
}
639
640
if ( ! function_exists('old')) {
641
    /**
642
     * Retrieve an old input item.
643
     * 
644
     * @param  string|null  $key
645
     * @param  mixed  $default
646
     * 
647
     * @return mixed
648
     */
649
    function old($key = null, $default = null)
650
    {
651
        return app('request')->old($key, $default);
0 ignored issues
show
Bug introduced by
The method old() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

651
        return app('request')->/** @scrutinizer ignore-call */ old($key, $default);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
652
    }
653
}
654
655
if ( ! function_exists('redirect')) {
656
    /**
657
     * Get an instance of the redirect.
658
     *
659
     * @param  string|null  $url  The url  
660
     * @param  int   $code  The redirect status code  
661
     * @param  array  $headers  An array of headers
662
     * @param  bool|null  $secure  Type of protocol (http|https)  
663
     *
664
     * @return \Syscodes\Components\Routing\Supported\Redirector|\Syscodes\Components\Http\RedirectResponse
0 ignored issues
show
Bug introduced by
The type Syscodes\Components\Routing\Supported\Redirector was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
665
     */
666
    function redirect($url = null, int $code = 302, array $headers = [], bool $secure = null)
667
    {
668
        if (null === $url) {
669
            return app('redirect');
0 ignored issues
show
Bug Best Practice introduced by
The expression return app('redirect') also could return the type Syscodes\Components\Contracts\Core\Application which is incompatible with the documented return type Syscodes\Components\Http...ng\Supported\Redirector.
Loading history...
670
        }
671
        
672
        return app('redirect')->to($url, $code, $headers, $secure);
0 ignored issues
show
Bug introduced by
The method to() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

672
        return app('redirect')->/** @scrutinizer ignore-call */ to($url, $code, $headers, $secure);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
673
    }
674
}
675
676
if ( ! function_exists('report')) {
677
    /**
678
     * The report an exception.
679
     * 
680
     * @param  \Throwable|string  $xception
681
     * 
682
     * @return void
683
     */
684
    function report($exception)
685
    {
686
        if (is_string($exception)) {
687
            $exception = new Exception($exception);
688
        }
689
690
        app(ExceptionHandler::class)->report($exception);
0 ignored issues
show
Bug introduced by
The method report() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

690
        app(ExceptionHandler::class)->/** @scrutinizer ignore-call */ report($exception);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
691
    }
692
}
693
694
if ( ! function_exists('request')) {
695
    /**
696
     * Get an instance of the current request or an input item from the request.
697
     * 
698
     * @param  array|string|null  $key  
699
     * @param  mixed  $default  
700
     * 
701
     * @return \Syscodes\Components\Http\Request|string|array 
702
     */
703
    function request($key = null, mixed $default = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
704
    {
705
        if (null === $key) {
706
            return app('request');
0 ignored issues
show
Bug Best Practice introduced by
The expression return app('request') also could return the type Syscodes\Components\Contracts\Core\Application which is incompatible with the documented return type Syscodes\Components\Http\Request|array|string.
Loading history...
707
        }
708
        
709
        if (is_array($key)) {
710
            return app('request')->only($key);
0 ignored issues
show
Bug introduced by
The method only() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

710
            return app('request')->/** @scrutinizer ignore-call */ only($key);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
711
        }
712
713
        $value = app('request')->__get($key);
0 ignored issues
show
Bug introduced by
The method __get() does not exist on Syscodes\Components\Contracts\Core\Application. Since it exists in all sub-types, consider adding an abstract or default implementation to Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

713
        $value = app('request')->/** @scrutinizer ignore-call */ __get($key);
Loading history...
714
715
        return null === $value ? value($default) : $value;
716
    }
717
}
718
719
if ( ! function_exists('resolve')) {
720
    /**
721
     * Resolve a service from the container.
722
     * 
723
     * @param  string  $id
724
     * @param  array  $parameters
725
     * 
726
     * @return mixed
727
     */
728
    function resolve($id, array $parameters = []) 
729
    {
730
        return app($id, $parameters);
731
    }
732
}
733
734
if ( ! function_exists('response')) {
735
    /**
736
     * Return a new Response from the application.
737
     *
738
     * @param  string  $body
739
     * @param  int  $status  
740
     * @param  array  $headers
741
     * 
742
     * @return \Syscodes\Components\Http\Response|\Syscodes\Components\Routing\Generators\RouteResponse
743
     */
744
    function response($body = '', int $status = 200, array $headers = [])
745
    {
746
        $response = app(RouteResponse::class);
747
748
        if (func_num_args() === 0) {
749
            return $response;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $response also could return the type Syscodes\Components\Contracts\Core\Application which is incompatible with the documented return type Syscodes\Components\Http...enerators\RouteResponse.
Loading history...
750
        }
751
752
        return $response->make($body, $status, $headers);
0 ignored issues
show
Bug introduced by
$status of type integer is incompatible with the type array expected by parameter $parameters of Syscodes\Components\Cont...ainer\Container::make(). ( Ignorable by Annotation )

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

752
        return $response->make($body, /** @scrutinizer ignore-type */ $status, $headers);
Loading history...
Unused Code introduced by
The call to Syscodes\Components\Cont...ainer\Container::make() has too many arguments starting with $headers. ( Ignorable by Annotation )

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

752
        return $response->/** @scrutinizer ignore-call */ make($body, $status, $headers);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
753
    }
754
}
755
756
if ( ! function_exists('resourcePath')) {
757
    /**
758
     * Get the path to the resources folder.
759
     *
760
     * @param  string  $path
761
     * 
762
     * @return string
763
     */
764
    function resourcePath($path = '')
765
    {
766
        return app()->resourcePath($path);
767
    }
768
}
769
770
if ( ! function_exists('route')) {
771
    /**
772
     * Get the URL to a named route.
773
     * 
774
     * @param  string  $name
775
     * @param  array  $parameters
776
     * @param  bool  $forced  
777
     * @param  \Syscodes\Components\Routing\Route|null  $route  
778
     * 
779
     * @return string
780
     */
781
    function route($name, array $parameters = [], bool $forced = true, $route = null)
782
    {
783
        return app('url')->route($name, $parameters, $forced, $route);
0 ignored issues
show
Bug introduced by
The method route() does not exist on Syscodes\Components\Contracts\Core\Application. ( Ignorable by Annotation )

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

783
        return app('url')->/** @scrutinizer ignore-call */ route($name, $parameters, $forced, $route);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
784
    }
785
}
786
787
if ( ! function_exists('secureAsset')) {
788
    /**
789
     * Generate an asset path for the application.
790
     * 
791
     * @param  string  $path
792
     * 
793
     * @return string
794
     */
795
    function secureAsset($path)
796
    {
797
        return asset($path, true);
798
    }
799
}
800
801
if ( ! function_exists('secureUrl')) {
802
    /**
803
     * Generate a HTTPS URL for the application.
804
     * 
805
     * @param  string  $path
806
     * @param  array  $parameters
807
     * 
808
     * @return string
809
     */
810
    function secureUrl($path, array $parameters = [])
811
    {
812
        return url($path, $parameters, true);
813
    }
814
}
815
816
if ( ! function_exists('session')) {
817
    /**
818
     * Get / set the specified session value.
819
     * 
820
     * @param  string  $key  
821
     * @param  mixed  $default  
822
     * 
823
     * @return mixed|\Syscodes\Components\Session\Store|\Syscodes\Components\Session\SessionManager
824
     */
825
    function session($key = null, mixed $default = null)
826
    {
827
        if (is_null($key)) {
828
            return app('session');
829
        }
830
831
        if (is_array($key)) {
0 ignored issues
show
introduced by
The condition is_array($key) is always false.
Loading history...
832
            return app('session')->put($key, $default);
833
        }
834
835
        return app('session')->get($key, $default);
0 ignored issues
show
Unused Code introduced by
The call to Psr\Container\ContainerInterface::get() has too many arguments starting with $default. ( Ignorable by Annotation )

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

835
        return app('session')->/** @scrutinizer ignore-call */ get($key, $default);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
836
    }
837
}
838
839
if ( ! function_exists('segment')) {
840
  /**
841
     * Returns the desired segment, or $default if it does not exist.
842
     *
843
     * @param  int  $segment  
844
     * @param  mixed  $default  
845
     *
846
     * @return string
847
     */
848
    function segment($index, $default = null)
849
    {
850
        return request()->segment($index, $default);
851
    }
852
}
853
854
if ( ! function_exists('segments')) {
855
  /**
856
     * Returns all segments in an array.
857
     *
858
     * @return array
859
     */
860
    function segments()
861
    {
862
        return request()->segments();
863
    }
864
}
865
866
if ( ! function_exists('storagePath')) {
867
    /**
868
     * Get the path to the storage folder.
869
     *
870
     * @param  string  $path
871
     * 
872
     * @return string
873
     */
874
    function storagePath($path = '')
875
    {
876
        return app('path.storage').($path ? DIRECTORY_SEPARATOR.$path : $path);
0 ignored issues
show
Bug introduced by
Are you sure app('path.storage') of type Syscodes\Components\Cont...\Core\Application|mixed can be used in concatenation? ( Ignorable by Annotation )

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

876
        return /** @scrutinizer ignore-type */ app('path.storage').($path ? DIRECTORY_SEPARATOR.$path : $path);
Loading history...
877
    }
878
}
879
880
if ( ! function_exists('to_route')) {
881
    /**
882
     * Create a new redirect response to a named route.
883
     * 
884
     * @param  string  $route
885
     * @param  mixed  $parameters
886
     * @param  int  $status
887
     * @param  array  $headers
888
     * 
889
     * @return \Syscodes\Components\Http\RedirectResponse
890
     */
891
    function to_route($route, $parameters = [], $status = 302, $headers = [])
892
    {
893
        return redirect()->route($route, $parameters, $status, $headers);
0 ignored issues
show
Bug introduced by
The method route() does not exist on Syscodes\Components\Http\RedirectResponse. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

893
        return redirect()->/** @scrutinizer ignore-call */ route($route, $parameters, $status, $headers);
Loading history...
894
    }
895
}
896
897
if ( ! function_exists('today')) {
898
    
899
    /**
900
     * Create a new Carbon instance for the current date.
901
     * 
902
     * @param  \DateTimeZone|string|null  $tz
903
     * 
904
     * @return \Syscodes\Components\Support\Chronos
905
     */
906
    function today($tz = null)
907
    {
908
        return Date::today($tz);
0 ignored issues
show
Bug introduced by
It seems like $tz can also be of type DateTimeZone; however, parameter $timezone of Syscodes\Components\Support\Facades\Date::today() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

908
        return Date::today(/** @scrutinizer ignore-type */ $tz);
Loading history...
909
    }
910
}
911
912
if ( ! function_exists('totalSegments')) {
913
  /**
914
     * Returns the total number of segment.
915
     *
916
     * @return int
917
     */
918
    function totalSegments()
919
    {
920
        return request()->totalSegments();
921
    }
922
}
923
924
if ( ! function_exists('trans')) {
925
    /**
926
     * A convenience method to translate a string and format it
927
     * with the intl extension's MessageFormatter object.
928
     * 
929
     * @param  strin|null  $line
930
     * @param  array  $replace
931
     * @param  string|null  $locale
932
     * 
933
     * @return \Syscode\Components\Contracts\Translation\Translator|string|array|null
0 ignored issues
show
Bug introduced by
The type Syscode\Components\Contr...\Translation\Translator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
934
     */
935
    function trans($key = null, array $replace = [], $locale = null)
936
    {
937
        if (is_null($key)) {
938
            return app('translator');
939
        }
940
941
        return app('translator')->get($key, $replace, $locale);
0 ignored issues
show
Unused Code introduced by
The call to Psr\Container\ContainerInterface::get() has too many arguments starting with $replace. ( Ignorable by Annotation )

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

941
        return app('translator')->/** @scrutinizer ignore-call */ get($key, $replace, $locale);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
942
    }
943
}
944
945
if ( ! function_exists('__')) {
946
    /**
947
     * A convenience method to translate a string and format it
948
     * with the intl extension's MessageFormatter object.
949
     * 
950
     * @param  string|null  $key
951
     * @param  array  $replace
952
     * @param  string|null  $locale
953
     * 
954
     * @return string|array|null
955
     */
956
    function __($key = null, array $replace = [], $locale = null)
957
    {
958
        if (is_null($key)) {
959
            return $key;
960
        }
961
962
        return trans($key, $replace, $locale);        
963
    }
964
}
965
966
if ( ! function_exists('url')) {
967
    /**
968
     * Generate a URL for the application.
969
     *
970
     * @param  string|null  $path  
971
     * @param  array  $parameters
972
     * @param  bool|null  $secure  
973
     *
974
     * @return \Syscodes\Components\Routing\Supported\UrlGenerator
975
     */
976
    function url($path = null, array $parameters = [], bool $secure = null)
977
    {
978
        if (is_null($path)) {
979
            return app(UrlGenerator::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return app(Syscodes\Comp...ed\UrlGenerator::class) also could return the type Syscodes\Components\Contracts\Core\Application which is incompatible with the documented return type Syscodes\Components\Routing\Supported\UrlGenerator.
Loading history...
980
        }
981
982
        return app(UrlGenerator::class)->to($path, $parameters, $secure);
983
    }
984
}
985
986
if ( ! function_exists('view')) {
987
    /**
988
     * Returns a new View object. If you do not define the "file" parameter, 
989
     * you must call [$this->view].
990
     *
991
     * @example $view->make($file, $data);
992
     *  
993
     * @param  string|null  $file  View filename
994
     * @param  array  $data  Array of values
995
     * 
996
     * @return \Syscodes\Components\View\View|\Syscodes\Components\Contracts\View\Factory
997
     */
998
    function view($file = null, $data = [])
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
999
    {
1000
        $view = app(Factory::class);
1001
1002
        if (func_num_args() === 0) {
1003
            return $view;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $view also could return the type Syscodes\Components\Contracts\Core\Application which is incompatible with the documented return type Syscodes\Components\Cont...es\Components\View\View.
Loading history...
1004
        }
1005
1006
        return $view->make($file, $data);
1007
    }
1008
}