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

File   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 68.42%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 82
c 1
b 0
f 0
wmc 8
lcom 1
cbo 5
ccs 13
cts 19
cp 0.6842
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getExtension() 0 4 1
A getDirectoryName() 0 4 1
A getFileName() 0 4 1
A __construct() 0 6 1
A toVOString() 0 4 1
A toXml() 0 4 1
A toJson() 0 4 1
A toYaml() 0 4 1
1
<?php namespace BestServedCold\PhalueObjects;
2
3
use BestServedCold\PhalueObjects\Format\Json;
4
use BestServedCold\PhalueObjects\Format\Xml;
5
use BestServedCold\PhalueObjects\Format\Yaml;
6
7
/**
8
 * Class File
9
 *
10
 * @package BestServedCold\PhalueObjects
11
 */
12
abstract class File extends ValueObject
0 ignored issues
show
Coding Style introduced by
File does not seem to conform to the naming convention (^Abstract|Factory$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
13
{
14
    /**
15
     * @var int
16
     */
17
    protected $timeout;
18
19
    /**
20
     * @var bool
21
     */
22
    protected $mustExist;
23
24
    /**
25
     * File constructor.
26
     *
27
     * @param string $value
28
     * @param bool   $mustExist
29
     * @param int    $timeout
30
     */
31 5
    public function __construct($value, $mustExist = true, $timeout = 10)
32
    {
33 5
        parent::__construct($value);
34 5
        $this->timeout = $timeout;
35 5
        $this->mustExist = $mustExist;
36 5
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getExtension()
42
    {
43
        return pathinfo($this->getValue(), PATHINFO_EXTENSION);
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getDirectoryName()
50
    {
51
        return pathinfo($this->getValue(), PATHINFO_DIRNAME);
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getFileName()
58
    {
59
        return pathinfo($this->getValue(), PATHINFO_FILENAME);
60
    }
61
62
    /**
63
     * @return VOString
64
     */
65 1
    public function toVOString()
66
    {
67 1
        return new VOString($this->getValue());
68
    }
69
70
    /**
71
     * @return Xml
72
     */
73 1
    public function toXml()
74
    {
75 1
        return Xml::fromString($this->getValue());
76
    }
77
78
    /**
79
     * @return Json
80
     */
81 1
    public function toJson()
82
    {
83 1
        return Json::fromString($this->getValue());
84
    }
85
86
    /**
87
     * @return Yaml
88
     */
89 1
    public function toYaml()
90
    {
91 1
        return Yaml::fromString($this->getValue());
92
    }
93
}
94