MakesResponses   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A success() 0 4 1
A error() 0 4 1
1
<?php
2
3
namespace Flugg\Responder\Http;
4
5
use Flugg\Responder\Http\Responses\ErrorResponseBuilder;
6
use Flugg\Responder\Http\Responses\SuccessResponseBuilder;
7
use Flugg\Responder\Responder;
8
9
/**
10
 * A trait to be used by controllers to easily make success- and error responses.
11
 *
12
 * @package flugger/laravel-responder
13
 * @author  Alexander Tømmerås <[email protected]>
14
 * @license The MIT License
15
 */
16
trait MakesResponses
17
{
18
    /**
19
     * Build a successful response.
20
     *
21
     * @param  mixed                                                          $data
22
     * @param  callable|string|\Flugg\Responder\Transformers\Transformer|null $transformer
23
     * @param  string|null                                                    $resourceKey
24
     * @return \Flugg\Responder\Http\Responses\SuccessResponseBuilder
25
     */
26 2
    public function success($data = null, $transformer = null, string $resourceKey = null): SuccessResponseBuilder
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed.

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

Loading history...
Unused Code introduced by
The parameter $transformer is not used and could be removed.

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

Loading history...
Unused Code introduced by
The parameter $resourceKey is not used and could be removed.

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

Loading history...
27
    {
28 2
        return app(Responder::class)->success(...func_get_args());
29
    }
30
31
    /**
32
     * Build an error response.
33
     *
34
     * @param  mixed|null  $errorCode
35
     * @param  string|null $message
36
     * @return \Flugg\Responder\Http\Responses\ErrorResponseBuilder
37
     */
38 2
    public function error($errorCode = null, string $message = null): ErrorResponseBuilder
0 ignored issues
show
Unused Code introduced by
The parameter $errorCode is not used and could be removed.

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

Loading history...
Unused Code introduced by
The parameter $message is not used and could be removed.

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

Loading history...
39
    {
40 2
        return app(Responder::class)->error(...func_get_args());
41
    }
42
}