RouteCollection::match()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace BeyondCode\Mailbox\Routing;
4
5
use BeyondCode\Mailbox\InboundEmail;
6
use Illuminate\Support\Collection;
7
8
class RouteCollection
9
{
10
    protected $routes = [];
11
12
    public function add(Route $route)
13
    {
14
        $this->routes[] = $route;
15
    }
16
17
    public function match(InboundEmail $message): Collection
18
    {
19
        return Collection::make($this->routes)->filter(function ($route) use ($message) {
0 ignored issues
show
Bug introduced by
$this->routes of type array is incompatible with the type Illuminate\Contracts\Support\Arrayable expected by parameter $items of Illuminate\Support\Collection::make(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

19
        return Collection::make(/** @scrutinizer ignore-type */ $this->routes)->filter(function ($route) use ($message) {
Loading history...
20
            return $route->matches($message);
21
        });
22
    }
23
}
24