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

RouteUrlsNormalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 23
ccs 8
cts 8
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 6 1
A normalizeUrl() 0 7 1
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