Completed
Push — master ( 5b0aeb...fbd885 )
by Iman
13:55 queued 10:37
created

RouterEventManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 24
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findMatchingCallbacks() 0 8 2
A getMatched() 0 5 3
1
<?php
2
3
namespace Imanghafoori\HeyMan\WatchingStrategies;
4
5
use Illuminate\Support\Str;
6
7
class RouterEventManager extends BaseManager
8
{
9
    protected $type = 'route';
10
11
    private $matchedCallbacks = [];
12
13 51
    public function findMatchingCallbacks(array $matchedRoute): array
14
    {
15 51
        $this->matchedCallbacks = [];
16 51
        foreach (array_filter($matchedRoute) as $info) {
17 51
            $this->getMatched($info);
18
        }
19
20 51
        return $this->matchedCallbacks;
21
    }
22
23
    /**
24
     * @param $info
25
     */
26 51
    private function getMatched(string $info)
27
    {
28 51
        foreach ($this->data as $routeInfo => $callBacks) {
29 46
            if (Str::is($routeInfo, $info)) {
30 46
                $this->matchedCallbacks[] = $callBacks['default'];
31
            }
32
        }
33 51
    }
34
}
35