Transformation::make()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Flugg\Responder;
4
5
use Flugg\Responder\Serializers\NoopSerializer;
6
7
/**
8
 * A class responsible for obtaining a transformation to transform data without serializing.
9
 *
10
 * @package flugger/laravel-responder
11
 * @author  Alexander Tømmerås <[email protected]>
12
 * @license The MIT License
13
 */
14
class Transformation
15
{
16
    /**
17
     * A builder used to build transformed arrays.
18
     *
19
     * @var \Flugg\Responder\TransformBuilder
20
     */
21
    protected $transformBuilder;
22
23
    /**
24
     * Construct the service class.
25
     *
26
     * @param \Flugg\Responder\TransformBuilder $transformBuilder
27
     */
28 1
    public function __construct(TransformBuilder $transformBuilder)
29
    {
30 1
        $this->transformBuilder = $transformBuilder;
31 1
    }
32
33
    /**
34
     * Make a new transformation to transform data without serializing.
35
     *
36
     * @param  mixed                                                          $data
37
     * @param  \Flugg\Responder\Transformers\Transformer|callable|string|null $transformer
38
     * @param  string|null                                                    $resourceKey
39
     * @return \Flugg\Responder\TransformBuilder
40
     */
41 1
    public function make($data = null, $transformer = null, string $resourceKey = null): TransformBuilder
42
    {
43 1
        return $this->transformBuilder->resource($data, $transformer, $resourceKey)->serializer(new NoopSerializer);
44
    }
45
}