Completed
Push — master ( 432495...dc645f )
by Iman
04:27
created

RouteUrlsNormalizer::normalize()   A

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