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

RouterEventManager::getMatched()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 3
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 3
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
    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