RequestDestinationFactory::createFromRequest()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.3332

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 6
cts 9
cp 0.6667
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 4
nop 2
crap 3.3332
1
<?php
2
3
namespace Bankiru\Seo\Listener;
4
5
use Bankiru\Seo\Destination;
6
use Symfony\Component\HttpFoundation\Request;
7
8
final class RequestDestinationFactory
9
{
10 2
    public static function createFromRequest(Request $request, array $destination)
11
    {
12 2
        if (array_keys($destination) === range(0, count($destination) - 1)) {
13
            $destination = array_combine($destination, $destination);
14
        }
15
16 2
        $attrs = [];
17 2
        foreach ($destination as $seo => $attribute) {
18
            $attrs[$seo] = $request->attributes->get($attribute);
19 2
        }
20
21 2
        return new Destination($request->attributes->get('_route'), $attrs);
22
    }
23
}
24