JavaScriptServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 4 1
A boot() 0 14 1
1
<?php namespace Blok\JavaScript;
2
3
use Illuminate\Support\Facades\Blade;
4
use Illuminate\Support\ServiceProvider;
5
6
class JavaScriptServiceProvider extends ServiceProvider
7
{
8
    protected $defer = false;
9
10
    public function register()
11
    {
12
        $this->app->singleton('JavaScript', function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

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

12
        $this->app->singleton('JavaScript', function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
13
            return new JavaScript(config('javascript.namespace'));
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

13
            return new JavaScript(/** @scrutinizer ignore-call */ config('javascript.namespace'));
Loading history...
14
        });
15
    }
16
17
    public function boot()
18
    {
19
        require_once __DIR__ . '/helpers.php';
20
21
        $this->publishes([
22
            __DIR__ . '/config/javascript.php' => config_path('javascript.php'),
0 ignored issues
show
Bug introduced by
The function config_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

22
            __DIR__ . '/config/javascript.php' => /** @scrutinizer ignore-call */ config_path('javascript.php'),
Loading history...
23
        ], 'config');
24
25
        /**
26
         * @example
27
         * @javascript($namespace, (optional) $array)
28
         */
29
        Blade::directive('javascript', function ($expression) {
30
            return "<?php echo JavaScript::render({$expression}); ?>";
31
        });
32
    }
33
}