Completed
Push — master ( d19dfb...5b8d73 )
by Adam
13:31
created

File::isReachableUrl()   B

Complexity

Conditions 4
Paths 5

Size

Total Lines 29
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 29
ccs 0
cts 25
cp 0
rs 8.5806
cc 4
eloc 20
nc 5
nop 1
crap 20

3 Methods

Rating   Name   Duplication   Size   Complexity  
A File::getDirectoryName() 0 4 1
A File::getFileName() 0 4 1
A File::fromString() 0 4 1
1
<?php namespace BestServedCold\PhalueObjects;
2
3
class File extends ValueObject
4
{
5
    /**
6
     * @return bool
7
     */
8
    public function exists()
0 ignored issues
show
Coding Style introduced by
function exists() does not seem to conform to the naming convention (^(?:is|has|should|may|supports)).

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...
9
    {
10
        return file_exists($this->getValue());
11
    }
12
13
    /**
14
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|false?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
15
     */
16
    public function getContents()
17
    {
18
        return $this->exists() ? file_get_contents($this->getValue()) : false;
19
    }
20
21
    /**
22
     * @return string
23
     */
24
    public function getExtension()
25
    {
26
        return pathinfo($this->getValue(), PATHINFO_EXTENSION);
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function getDirectoryName()
33
    {
34
        return pathinfo($this->getValue(), PATHINFO_DIRNAME);
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function getFileName()
41
    {
42
        return pathinfo($this->getValue(), PATHINFO_FILENAME);
43
    }
44
45
    /**
46
     * @param string $string
47
     * @return static
48
     */
49
    public static function fromString($string)
50
    {
51
        return new static($string);
52
    }
53
}
54