1 | <?php |
||||||
2 | |||||||
3 | declare(strict_types=1); |
||||||
4 | |||||||
5 | namespace Nip\View\Traits; |
||||||
6 | |||||||
7 | use function defined; |
||||||
8 | use const DIRECTORY_SEPARATOR; |
||||||
9 | |||||||
10 | /** |
||||||
11 | * Trait HasPathsTrait. |
||||||
12 | */ |
||||||
13 | trait HasPathsTrait |
||||||
14 | { |
||||||
15 | /** |
||||||
16 | * @return string |
||||||
17 | */ |
||||||
18 | public function getBasePath() |
||||||
19 | 11 | { |
|||||
20 | if (null === $this->getDirectory()) { |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
21 | 11 | $this->initBasePath(); |
|||||
22 | 11 | } |
|||||
23 | |||||||
24 | return $this->getDirectory(); |
||||||
25 | 11 | } |
|||||
26 | |||||||
27 | /** |
||||||
28 | * @param string $path |
||||||
29 | * |
||||||
30 | * @return $this |
||||||
31 | * |
||||||
32 | 11 | * @deprecated use Set |
|||||
33 | */ |
||||||
34 | 11 | public function setBasePath($path) |
|||||
35 | 11 | { |
|||||
36 | 11 | $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|||||
37 | 11 | $this->setDirectory($path); |
|||||
0 ignored issues
–
show
It seems like
setDirectory() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
38 | $this->getResolveTemplatePath()->prependPath($path); |
||||||
0 ignored issues
–
show
It seems like
getResolveTemplatePath() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
39 | |||||||
40 | return $this; |
||||||
41 | } |
||||||
42 | |||||||
43 | abstract public function getFinder(); |
||||||
44 | |||||||
45 | 11 | protected function initBasePath() |
|||||
46 | { |
||||||
47 | 11 | $this->setBasePath($this->generateBasePath()); |
|||||
0 ignored issues
–
show
The function
Nip\View\Traits\HasPathsTrait::setBasePath() has been deprecated: use Set
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||||
48 | 11 | } |
|||||
49 | |||||||
50 | /** |
||||||
51 | * @return string|bool |
||||||
52 | */ |
||||||
53 | 11 | protected function generateBasePath() |
|||||
54 | { |
||||||
55 | 11 | if (defined('VIEWS_PATH')) { |
|||||
56 | return VIEWS_PATH; |
||||||
0 ignored issues
–
show
|
|||||||
57 | } |
||||||
58 | |||||||
59 | 11 | return false; |
|||||
60 | } |
||||||
61 | } |
||||||
62 |