Completed
Pull Request — master (#48)
by Vladimir
02:35
created

ReadableDocument::refreshFileContent()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 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\System\Filesystem;
11
use Symfony\Component\Filesystem\Exception\FileNotFoundException;
12
13
abstract class ReadableDocument
0 ignored issues
show
Coding Style introduced by
ReadableDocument 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...
14
{
15
    protected $filePath;
16
    protected $extension;
17
    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...
18
19 124
    public function __construct($filePath)
20
    {
21 124
        $this->fs = new Filesystem();
22 124
        $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 124
        $this->extension = strtolower($this->fs->getExtension($p));
25 124
        $this->refreshFileContent();
26 111
    }
27
28 67
    final public function getRelativeFilePath()
29
    {
30 67
        return $this->fs->getRelativePath($this->filePath);
31
    }
32
33 14
    final public function getExtension()
34
    {
35 14
        return $this->extension;
36
    }
37
38 66
    final public function getBaseName()
39
    {
40 66
        return $this->fs->getBaseName($this->filePath);
41
    }
42
43 26
    final public function getFilePath()
44
    {
45 26
        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