RouteCollection   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 13
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 3 1
A match() 0 4 1
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