Completed
Push — master ( 81fe53...e7743d )
by Pavel
02:34
created

RestServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 86.36%

Importance

Changes 0
Metric Value
dl 0
loc 38
ccs 19
cts 22
cp 0.8636
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 4 1
A registerResponses() 0 5 1
A registerDefaultRequests() 0 13 1
1
<?php namespace Pz\LaravelDoctrine\Rest;
2
3
use Illuminate\Support\ServiceProvider;
4
5
use Pz\Doctrine\Rest\Request\DeleteRequestInterface;
6
use Pz\Doctrine\Rest\Request\IndexRequestInterface;
7
use Pz\Doctrine\Rest\Request\ShowRequestInterface;
8
use Pz\Doctrine\Rest\Response\FractalResponse;
9
use Pz\Doctrine\Rest\RestResponseFactory;
10
use Pz\LaravelDoctrine\Rest\Request\DeleteRestRequest;
11
use Pz\LaravelDoctrine\Rest\Request\IndexRestRequest;
12
use Pz\LaravelDoctrine\Rest\Request\ShowRestRequest;
13
14
class RestServiceProvider extends ServiceProvider
15
{
16
    /**
17
     * Register laravel doctrine rest application.
18
     */
19 5
    public function register()
20
    {
21 5
        $this->registerDefaultRequests();
22 5
        $this->registerResponses();
23 5
    }
24
25
    /**
26
     * Register application requests.
27
     */
28 5
    protected function registerResponses()
29
    {
30 5
        $this->app->bind(RestResponseFactory::class, RestResponse::class);
31 5
        $this->app->bind(RestResponse::class, function() {
32 5
            return new RestResponse();
0 ignored issues
show
Bug introduced by
The call to Pz\LaravelDoctrine\Rest\...Response::__construct() has too few arguments starting with transformer. ( Ignorable by Annotation )

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

32
            return /** @scrutinizer ignore-call */ new RestResponse();

This check compares calls to functions or methods with their respective definitions. If the call has less 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...
33 5
        });
34 5
    }
35
36
    /**
37
     * Register default laravel requests.
38
     */
39 5
    protected function registerDefaultRequests()
40
    {
41 5
        $this->app->bind(IndexRequestInterface::class, IndexRestRequest::class);
42 5
        $this->app->bind(IndexRestRequest::class, function() {
43
            return new IndexRestRequest();
44 5
        });
45 5
        $this->app->bind(ShowRequestInterface::class, ShowRestRequest::class);
46 5
        $this->app->bind(ShowRestRequest::class, function() {
47
            return new ShowRestRequest();
48 5
        });
49 5
        $this->app->bind(DeleteRequestInterface::class, DeleteRestRequest::class);
50 5
        $this->app->bind(DeleteRestRequest::class, function() {
51
            return new DeleteRestRequest();
52 5
        });
53
    }
54
}
55