Passed
Branch v1.5.1 (ba2a89)
by Wanderson
03:18
created

Storable::getAbsolutePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Win\Repositories\Filesystem;
4
5
use Win\Models\DateTime;
0 ignored issues
show
Bug introduced by
The type Win\Models\DateTime was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
/**
8
 * Item dentro do Diretório
9
 * Podendo ser outro diretório, arquivos, etc
10
 */
11
abstract class Storable
12
{
13
	const REGEXP_PATH = '@^(([a-zA-Z0-9._\-][\/]?))+$@';
14
	const REGEXP_NAME = '@^(([a-zA-Z0-9._\-]?))+$@';
15
	const DS = DIRECTORY_SEPARATOR;
16
17
	/** @var string */
18
	private $path;
19
20
	/** @var Directory */
21
	private $directory;
22
23
	/** @return string */
24
	public function __toString()
25
	{
26
		return $this->getPath();
27
	}
28
29
	/** @return string */
30
	public function getPath()
31
	{
32
		return $this->path;
33
	}
34
35
	/** @return string */
36
	public function getAbsolutePath()
37
	{
38
		return BASE_PATH . static::DS . $this->path;
39
	}
40
41
	/**
42
	 * Retorna o diretório pai
43
	 * @return Directory
44
	 */
45
	public function getDirectory()
46
	{
47
		if (is_null($this->directory)) {
48
			$path = pathinfo($this->getPath(), PATHINFO_DIRNAME);
49
			$this->directory = new Directory($path);
50
		}
51
52
		return $this->directory;
53
	}
54
55
	/** @return string */
56
	public function getName()
57
	{
58
		return pathinfo($this->getAbsolutePath(), PATHINFO_FILENAME);
59
	}
60
61
	/** @return string */
62
	public function getBaseName()
63
	{
64
		return pathinfo($this->getAbsolutePath(), PATHINFO_BASENAME);
65
	}
66
67
	/** @return string */
68
	public function getUpdatedAt()
69
	{
70
		$ts = filemtime($this->getAbsolutePath());
71
72
		return date('Y-m-d H:i:s', $ts);
73
	}
74
75
	/** @param string $path */
76
	protected function setPath($path)
77
	{
78
		$this->path = $path;
79
	}
80
}
81