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

File::getFileName()   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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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