Completed
Push — master ( 80d5dd...e32bbf )
by Vladimir
03:02
created

ReadableDocument::getExtension()   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
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
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\Document;
9
10
use allejo\stakx\Document\DocumentInterface;
11
use allejo\stakx\Filesystem\File;
12
use allejo\stakx\System\Filesystem;
13
14
abstract class ReadableDocument implements DocumentInterface
15
{
16
    /** @var string */
17
    protected $filePath;
18
    /** @var string */
19
    protected $extension;
20
    /** @var Filesystem */
21
    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...
22
23
    /**
24
     * @param string $filePath
0 ignored issues
show
Documentation introduced by
Should the type for parameter $filePath not be File?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
25
     */
26 148
    public function __construct(File $filePath)
27
    {
28 148
        $this->fs = new Filesystem();
29 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...
30
31 148
        $this->extension = strtolower($this->fs->getExtension($p));
32 148
        $this->refreshFileContent();
33 135
    }
34
35 79
    final public function getRelativeFilePath()
36
    {
37 79
        return $this->fs->getRelativePath($this->filePath);
38
    }
39
40 14
    final public function getExtension()
41
    {
42 14
        return $this->extension;
43
    }
44
45 51
    final public function getBaseName()
46
    {
47 51
        return $this->fs->getBaseName($this->filePath);
48
    }
49
50 23
    final public function getAbsoluteFilePath()
51
    {
52 23
        return $this->filePath;
53
    }
54
55 31
    final public function getFileName()
56
    {
57 31
        return $this->fs->getFileName($this->filePath);
58
    }
59
60
    abstract public function refreshFileContent();
61
}
62