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

Local::fromRequestFile()   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 2
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\File as RequestFile;
6
7
/**
8
 * Class Local
9
 *
10
 * @package BestServedCold\PhalueObjects\File
11
 */
12
class Local extends File
13
{
14
    /**
15
     * @param  RequestFile $url
16
     * @return static
17
     */
18
    public static function fromRequestFile(RequestFile $url)
19
    {
20
        return new static($url->getContents());
21
    }
22
23
    /**
24
     * @param  string $path
25
     * @return static
26
     */
27
    public static function fromPath($path)
28
    {
29
        if (! is_string($path)) {
30
            throw new InvalidTypeException($path, [ 'path' ]);
31
        }
32
33
        return static::fromRequestFile(RequestFile::fromPath($path));
34
    }
35
}
36