SetTransformAttributeMiddlewareFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 6
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Alchemy\RestProvider\Middleware;
4
5
use Symfony\Component\HttpFoundation\Request;
6
7
class SetTransformAttributeMiddlewareFactory
8
{
9
    public function __invoke($transformerKey, $isList)
10
    {
11 2
        return function (Request $request) use ($transformerKey, $isList) {
12 2
            $restAttribute = $request->attributes->get('_rest', array());
13
14 2
            $restAttribute['transform'] = $transformerKey;
15 2
            $restAttribute['list'] = (bool) $isList;
16
17 2
            $request->attributes->set('_rest', $restAttribute);
18 2
        };
19
    }
20
}
21