Completed
Push — master ( d096a8...68247b )
by Jasper
05:13
created

ServiceProvider::getResponseMacroName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Swis\Laravel\JavaScriptData;
4
5
use Illuminate\Support\Facades\Response;
6
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
7
8
class ServiceProvider extends BaseServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     */
13 9
    public function boot()
14
    {
15 9
        $this->publishes([__DIR__.'/../config/' => config_path()], 'config');
16
17 9
        $this->registerResponseMacro($this->getResponseMacroName());
18 9
    }
19
20
    /**
21
     * Register the application services.
22
     */
23 9
    public function register()
24
    {
25 9
        $this->mergeConfigFrom(__DIR__.'/../config/javascript-data-response.php', 'javascript-data-response');
26
27 9
        $this->app->singleton(Builder::class);
28 9
    }
29
30
    /**
31
     * Response macro for JavaScript data.
32
     *
33
     * @param string $name
34
     */
35 9
    protected function registerResponseMacro(string $name)
36
    {
37 9
        Response::macro(
38 9
            $name,
39 9
            function () {
40 3
                $builder = app(Builder::class);
41 3
                $factory = new ResponseFactory(/* @scrutinizer ignore-type */ $this, $builder);
42
43 3
                return $factory->make(...\func_get_args());
0 ignored issues
show
Bug introduced by
func_get_args() is expanded, but the parameter $name of Swis\Laravel\JavaScriptD...ResponseFactory::make() 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

43
                return $factory->make(/** @scrutinizer ignore-type */ ...\func_get_args());
Loading history...
44 9
            }
45
        );
46 9
    }
47
48 9
    protected function getResponseMacroName(): string
49
    {
50 9
        return 'javascriptData';
51
    }
52
}
53