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

File   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 46
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1
ccs 11
cts 11
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fromFileObject() 0 4 1
A fromPath() 0 4 1
A getContents() 0 4 1
A getInfo() 0 4 1
1
<?php
2
3
namespace BestServedCold\PhalueObjects\Request;
4
5
use BestServedCold\PhalueObjects\Contract\Request;
6
use BestServedCold\PhalueObjects\VOObject;
7
8
/**
9
 * Class File
10
 *
11
 * @package BestServedCold\PhalueObjects\Request
12
 */
13
class File extends VOObject implements Request
14
{
15
    /**
16
     * File constructor.
17
     *
18
     * @param \SplFileObject $value
19
     */
20 5
    public function __construct(\SplFileObject $value)
21
    {
22 5
        parent::__construct($value);
23 5
    }
24
25
    /**
26
     * @param  \SplFileObject $splFileObject
27
     * @return static
28
     */
29 4
    public static function fromFileObject(\SplFileObject $splFileObject)
30
    {
31 4
        return new static($splFileObject);
32
    }
33
34
    /**
35
     * @param $path
36
     * @return static
37
     */
38 3
    public static function fromPath($path)
39
    {
40 3
        return static::fromFileObject(new \SplFileObject($path));
41
    }
42
43
    /**
44
     * @return string
45
     */
46 1
    public function getContents()
47
    {
48 1
        return $this->getValue()->fread($this->getValue()->getSize());
49
    }
50
51
    /**
52
     * @return \SplFileObject
53
     */
54 1
    public function getInfo()
55
    {
56 1
        return $this->getValue()->getFileInfo($this->getType());
57
    }
58
}
59