Completed
Push — master ( f23544...53e301 )
by Freek
02:50
created

InvalidUrl   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 11
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A unexpectedType() 0 8 2
1
<?php
2
3
namespace Spatie\Crawler\Exception;
4
5
use Exception;
6
use Psr\Http\Message\UriInterface;
7
use Spatie\Crawler\CrawlUrl;
8
9
class InvalidUrl extends Exception
10
{
11
    public static function unexpectedType($url)
12
    {
13
        $crawlUrlClass = CrawlUrl::class;
14
        $uriInterfaceClass = UriInterface::class;
15
        $givenUrlClass = is_object($url) ? get_class($url) : gettype($url);
16
17
        return new static("You passed an invalid url of type `{$givenUrlClass}`. This should be either a {$crawlUrlClass} or `{$uriInterfaceClass}`");
18
    }
19
}
20
21
22
23