Request::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Raidros\Storer;
4
5
class Request
6
{
7
    protected $request;
8
    protected $transformer;
9
10
    /**
11
     * Configure a api request.
12
     *
13
     * @param array            $request
14
     * @param Transformer|null $transformer
15
     */
16 15
    public function __construct(array $request, Transformer $transformer = null)
17
    {
18 15
        $this->request = $request;
19 15
        $this->transformer = $transformer;
20 15
    }
21
22
    /**
23
     * return the transformed request body.
24
     *
25
     * @param string $keyChain
26
     *
27
     * @return array
28
     */
29 15
    public function getBody($keyChain)
30
    {
31 15
        if ($this->transformer) {
32 3
            $this->request[$keyChain] = $this->transformer->transformData($this->request[$keyChain]);
33 3
        }
34
35 15
        return $this->request;
36
    }
37
}
38