Passed
Push — master ( e985ab...f5765f )
by Mihail
04:35
created

View::getCurrentPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Ffcms\Core\Arch;
4
5
use Ffcms\Core\App;
6
use Ffcms\Core\Helper\Type\Str;
7
use Ffcms\Templex\Engine;
0 ignored issues
show
Bug introduced by
The type Ffcms\Templex\Engine 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...
8
9
/**
10
 * Class View. Classic realisation of view's management in MVC architecture.
11
 * This class can be uses as object - (new View())->render() or from entry point App::$View->render() or
12
 * from controller action like $this->view->render()
13
 * @package Ffcms\Core\Arch
14
 * @property string $title
15
 * @property string $description
16
 * @property string $keywords
17
 * @property array $breadcrumbs
18
 */
19
class View extends Engine
20
{
21
    public $lang = 'en';
22
23
    private $path;
24
25
    /**
26
     * View constructor. Initialize template engine
27
     */
28
    public function __construct()
29
    {
30
        $this->lang = App::$Request->getLanguage();
31
        // get theme from config based on env_name global
32
        $theme = App::$Properties->get('theme')[env_name] ?? 'default';
0 ignored issues
show
Bug introduced by
The constant Ffcms\Core\Arch\env_name was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
33
        $env = ucfirst(Str::lowerCase(env_name));
34
35
        $this->path = root . DIRECTORY_SEPARATOR . 'Apps' . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR . $env . DIRECTORY_SEPARATOR . $theme;
0 ignored issues
show
Bug introduced by
The constant Ffcms\Core\Arch\root was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
36
37
        // initialize template engine with path and load default extensions
38
        parent::__construct($this->path);
39
        $this->loadDefaultExtensions();
40
    }
41
42
    /**
43
     * Get current template absolute path
44
     * @return string|null
45
     */
46
    public function getCurrentPath(): ?string
47
    {
48
        return $this->path;
49
    }
50
}
51