Passed
Push — master ( bf2aee...a6dc35 )
by Thierry
02:22
created

ViewTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 79
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDialog() 0 3 1
A getViewManager() 0 3 1
A getPaginator() 0 3 1
A getViewRenderer() 0 3 1
A registerViews() 0 31 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Di\Traits;
4
5
use Jaxon\Di\Container;
6
use Jaxon\Ui\Dialogs\DialogFacade;
7
use Jaxon\Ui\Pagination\Paginator;
8
use Jaxon\Ui\Pagination\PaginationRenderer;
9
use Jaxon\Ui\Template\TemplateView;
10
use Jaxon\Ui\View\ViewManager;
11
use Jaxon\Ui\View\ViewRenderer;
12
use Jaxon\Utils\Template\TemplateEngine;
0 ignored issues
show
Bug introduced by
The type Jaxon\Utils\Template\TemplateEngine 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...
13
14
trait ViewTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait ViewTrait
Loading history...
15
{
16
    /**
17
     * Register the values into the container
18
     *
19
     * @return void
20
     */
21
    private function registerViews()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
22
    {
23
        // Dialog Facade
24
        $this->set(DialogFacade::class, function($c) {
0 ignored issues
show
Bug introduced by
It seems like set() 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 ignore-call  annotation

24
        $this->/** @scrutinizer ignore-call */ 
25
               set(DialogFacade::class, function($c) {
Loading history...
25
            return new DialogFacade($c->g(Container::class));
26
        });
27
        // View Manager
28
        $this->set(ViewManager::class, function($c) {
29
            $xViewManager = new ViewManager($this);
30
            // Add the default view renderer
31
            $xViewManager->addRenderer('jaxon', function($di) {
32
                return new TemplateView($di->g(TemplateEngine::class));
33
            });
34
            $sTemplateDir = rtrim(trim($c->g('jaxon.core.dir.template')), '/\\');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
35
            $sPaginationDir = $sTemplateDir . DIRECTORY_SEPARATOR . 'pagination';
36
            // By default, render pagination templates with Jaxon.
37
            $xViewManager->addNamespace('jaxon', $sTemplateDir, '.php', 'jaxon');
38
            $xViewManager->addNamespace('pagination', $sPaginationDir, '.php', 'jaxon');
39
            return $xViewManager;
40
        });
41
        // View Renderer
42
        $this->set(ViewRenderer::class, function($c) {
43
            return new ViewRenderer($c->g(ViewManager::class));
44
        });
45
        // Pagination Paginator
46
        $this->set(Paginator::class, function($c) {
47
            return new Paginator($c->g(PaginationRenderer::class));
48
        });
49
        // Pagination Renderer
50
        $this->set(PaginationRenderer::class, function($c) {
51
            return new PaginationRenderer($c->g(ViewRenderer::class));
52
        });
53
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
54
55
    /**
56
     * Get the dialog wrapper
57
     *
58
     * @return DialogFacade
59
     */
60
    public function getDialog(): DialogFacade
61
    {
62
        return $this->g(DialogFacade::class);
0 ignored issues
show
Bug introduced by
It seems like g() 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 ignore-call  annotation

62
        return $this->/** @scrutinizer ignore-call */ g(DialogFacade::class);
Loading history...
63
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
64
65
    /**
66
     * Get the view manager
67
     *
68
     * @return ViewManager
69
     */
70
    public function getViewManager(): ViewManager
71
    {
72
        return $this->g(ViewManager::class);
73
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
74
75
    /**
76
     * Get the view facade
77
     *
78
     * @return ViewRenderer
79
     */
80
    public function getViewRenderer(): ViewRenderer
81
    {
82
        return $this->g(ViewRenderer::class);
83
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
84
85
    /**
86
     * Get the paginator
87
     *
88
     * @return Paginator
89
     */
90
    public function getPaginator(): Paginator
91
    {
92
        return $this->g(Paginator::class);
93
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
94
}
95