Passed
Push — master ( f8044c...6aa085 )
by Alexander
03:26
created

helpers.php ➔ transform()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 4
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Flugg\Responder\Contracts\Responder;
4
use Flugg\Responder\Contracts\Transformer;
5
6
if (! function_exists('responder')) {
7
8
    /**
9
     * A helper method to resolve the responder service out of the service container.
10
     *
11
     * @return \Flugg\Responder\Contracts\Responder
12
     */
13
    function responder(): Responder
14
    {
15 1
        return app(Responder::class);
16
    }
17
}
18
19
if (! function_exists('transform')) {
20
21
    /**
22
     * A helper method to transform data without serializing.
23
     *
24
     * @param  mixed                                                          $data
25
     * @param  \Flugg\Responder\Transformers\Transformer|callable|string|null $transformer
26
     * @param  string[]                                                       $with
27
     * @param  string[]                                                       $without
28
     * @return array
29
     */
30
    function transform($data = null, $transformer = null, array $with = [], array $without = []): array
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...
31
    {
32 1
        return app(Transformer::class)->transform($data, $transformer, $with, $without);
33
    }
34
}
35