Completed
Push — master ( 2a7c0c...5b0aeb )
by Iman
06:22
created

RouterEventManager::getMatched()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 3
nop 1
dl 0
loc 5
ccs 0
cts 0
cp 0
crap 12
rs 10
c 0
b 0
f 0
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