RouteUrlsNormalizer::normalize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\Plugins\WatchingStrategies\Routes;
4
5
final class RouteUrlsNormalizer
6
{
7 48
    public function normalize($method, $args)
8
    {
9 48
        $method = str_replace('VisitUrl', 'SendGet', $method);
10 48
        $method = str_replace('whenYouSend', '', $method);
11
12 48
        return [$this->normalizeUrl($args, strtoupper($method))];
13
    }
14
15
    private function normalizeUrl($urls, $verb = 'GET')
16
    {
17 48
        $removeSlash = function ($url) use ($verb) {
18 48
            return $verb.ltrim($url, '/');
19 48
        };
20
21 48
        return array_map($removeSlash, $urls);
22
    }
23
}
24