Completed
Push — master ( 2a7c0c...5b0aeb )
by Iman
06:22
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 7
cts 7
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 51
    private $matchedCallbacks = [];
12
13 51
    public function findMatchingCallbacks(array $matchedRoute): array
14 51
    {
15 46
        $this->matchedCallbacks = [];
16 46
        foreach (array_filter($matchedRoute) as $info) {
17 46
            $this->getMatched($info);
18
        }
19
20
        return $this->matchedCallbacks;
21
    }
22 51
23
    /**
24
     * @param $info
25
     */
26
    private function getMatched(string $info)
27
    {
28
        foreach ($this->data as $routeInfo => $callBacks) {
29
            if (Str::is($routeInfo, $info)) {
30
                $this->matchedCallbacks[] = $callBacks['default'];
31
            }
32
        }
33
    }
34
}
35