Passed
Push — v5 ( c0775f...b45ef7 )
by Alexey
16:22
created

Page::pageTag()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Inji\View\Parser;
4
class Page extends \Inji\View\Parser {
5
    /**
6
     * @var \Inji\View\Page
7
     */
8
    public $page;
9
10
    function __construct(\Inji\View\Page $page) {
11
        $this->page = $page;
12
    }
13
14
    function parse() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
15
        $html = '';
16
        if (file_exists($this->page->path)) {
17
            $source = file_get_contents($this->page->path);
18
            if (strpos($source, 'BODYEND') === false) {
19
                $source = str_replace('</body>', '{BODYEND}</body>', $source);
20
            }
21
            $html = $this->parseSource($source);
22
        }
23
        return $html;
24
    }
25
26
    function contentTag() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
27
        return $this->page->content->render();
0 ignored issues
show
Bug introduced by
The method render() does not exist on Inji\View\Content. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
        return $this->page->content->/** @scrutinizer ignore-call */ render();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
    }
29
30
    function titleTag() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
31
        return $this->page->title;
32
    }
33
34
    function widgetTag($widgetName, $params) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
35
        return $this->page->app->view->widget($widgetName, ['params' => $params], ':' . implode(':', $params));
0 ignored issues
show
Bug Best Practice introduced by
The property view does not exist on Inji\App. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
The method widget() does not exist on Inji\Module. It seems like you code against a sub-type of Inji\Module such as Inji\View or Inji\Db. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        return $this->page->app->view->/** @scrutinizer ignore-call */ widget($widgetName, ['params' => $params], ':' . implode(':', $params));
Loading history...
Bug introduced by
The method widget() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        return $this->page->app->view->/** @scrutinizer ignore-call */ widget($widgetName, ['params' => $params], ':' . implode(':', $params));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
    }
37
38
    function headTag() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
39
        return $this->page->head->generate();
40
    }
41
42
    function pageTag($pageName) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
43
        return $this->page->app->view->page(['page' => $pageName])->render();
0 ignored issues
show
Bug introduced by
The method page() does not exist on Inji\Module. It seems like you code against a sub-type of Inji\Module such as Inji\View or Inji\Db. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        return $this->page->app->view->/** @scrutinizer ignore-call */ page(['page' => $pageName])->render();
Loading history...
Bug Best Practice introduced by
The property view does not exist on Inji\App. Since you implemented __get, consider adding a @property annotation.
Loading history...
44
    }
45
46
    function bodyendTag() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
47
        return $this->page->bodyEnd();
0 ignored issues
show
Bug introduced by
The method bodyEnd() does not exist on Inji\View\Page. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
        return $this->page->/** @scrutinizer ignore-call */ bodyEnd();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
    }
49
50
    function template_pathTag() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
51
        return '/static/templates/' . $this->page->template->name;
52
    }
53
}