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

Url::fromCurlUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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