Completed
Push — master ( 89bfcf...4ab803 )
by Vladimir
02:41
created

ReadableFile::getFilePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * @copyright 2017 Vladimir Jimenez
5
 * @license   https://github.com/allejo/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\System;
9
10
abstract class ReadableFile
11
{
12
    protected $filePath;
13
    protected $extension;
14
    protected $fs;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $fs. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
15
16
    /**
17
     * @param string $filePath
18
     */
19 148
    public function __construct($filePath)
20
    {
21 148
        $this->fs = new Filesystem();
22 148
        $p = $this->filePath = $this->fs->absolutePath((string)$filePath);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $p. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
23
24 148
        $this->extension = strtolower($this->fs->getExtension($p));
25 148
        $this->refreshFileContent();
26 135
    }
27
28 79
    final public function getRelativeFilePath()
29
    {
30 79
        return $this->fs->getRelativePath($this->filePath);
31
    }
32
33 14
    final public function getExtension()
34
    {
35 14
        return $this->extension;
36
    }
37
38 50
    final public function getBaseName()
39
    {
40 50
        return $this->fs->getBaseName($this->filePath);
41
    }
42
43 23
    final public function getFilePath()
44
    {
45 23
        return $this->filePath;
46
    }
47
48 30
    final public function getFileName()
49
    {
50 30
        return $this->fs->getFileName($this->filePath);
51
    }
52
53
    abstract public function refreshFileContent();
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
54
}
55