View   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 14
c 2
b 0
f 1
dl 0
loc 36
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrentPath() 0 3 1
A __construct() 0 18 3
1
<?php
2
3
namespace Ffcms\Core\Arch;
4
5
use Ffcms\Core\App;
6
use Ffcms\Core\Helper\FileSystem\Directory;
7
use Ffcms\Core\Helper\Type\Str;
8
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...
9
10
/**
11
 * Class View. Classic realisation of view's management in MVC architecture.
12
 * This class can be uses as object - (new View())->render() or from entry point App::$View->render() or
13
 * from controller action like $this->view->render()
14
 * @package Ffcms\Core\Arch
15
 * @property string $title
16
 * @property string $description
17
 * @property string $keywords
18
 * @property array $breadcrumbs
19
 */
20
class View extends Engine
21
{
22
    public $lang = 'en';
23
24
    private $path;
25
26
    /**
27
     * View constructor. Initialize template engine
28
     */
29
    public function __construct()
30
    {
31
        $this->lang = App::$Request->getLanguage();
32
        // get theme from config based on env_name global
33
        $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...
34
        $env = ucfirst(Str::lowerCase(env_name));
35
36
        $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...
37
        if (!Directory::exist($this->path)) {
38
            if (App::$Debug) {
39
                App::$Debug->addMessage('Template root directory is not exist: ' . $this->path, 'error');
40
            }
41
            return;
42
        }
43
44
        // initialize template engine with path and load default extensions
45
        parent::__construct($this->path);
46
        $this->loadDefaultExtensions();
47
    }
48
49
    /**
50
     * Get current template absolute path
51
     * @return string|null
52
     */
53
    public function getCurrentPath(): ?string
54
    {
55
        return $this->path;
56
    }
57
}
58