Completed
Push — master ( 5c637b...29a871 )
by Adam
02:41
created

Url   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 24
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3
ccs 0
cts 11
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromCurlUrl() 0 4 1
A fromUrl() 0 8 2
1
<?php namespace BestServedCold\PhalueObjects\File;
2
3
use BestServedCold\PhalueObjects\Exception\InvalidTypeException;
4
use BestServedCold\PhalueObjects\File;
5
use BestServedCold\PhalueObjects\Request\Curl\Url as CurlUrl;
6
7
/**
8
 * Class Url
9
 *
10
 * @package BestServedCold\PhalueObjects\File
11
 */
12
class Url extends File
13
{
14
    /**
15
     * @param  CurlUrl $url
16
     * @return static
17
     */
18
    public static function fromCurlUrl(CurlUrl $url)
19
    {
20
        return new static($url->execute());
0 ignored issues
show
Bug introduced by
The method execute() does not seem to exist on object<BestServedCold\Ph...jects\Request\Curl\Url>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
21
    }
22
23
    /**
24
     * @param  string $url
25
     * @return static
26
     */
27
    public static function fromUrl($url)
28
    {
29
        if (! filter_var($url, FILTER_VALIDATE_URL)) {
30
            throw new InvalidTypeException($url, [ 'url' ]);
31
        }
32
33
        return static::fromCurlUrl(CurlUrl::auto([CURLOPT_URL => $url]));
34
    }
35
}
36