RequestDestinationFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 16
ccs 6
cts 9
cp 0.6667
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromRequest() 0 13 3
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