RenderFiles::isHeader()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 6
rs 10
c 1
b 0
f 0
cc 3
nc 2
nop 0
1
<?php
2
/**
3
 * KNUT7 K7F (https://marciozebedeu.com/)
4
 * KNUT7 K7F (tm) : Rapid Development Framework (https://marciozebedeu.com/).
5
 *
6
 * Licensed under The MIT License
7
 * For full copyright and license information, please see the LICENSE.txt
8
 * Redistributions of files must retain the above copyright notice.
9
 *
10
 * @see      https://github.com/knut7/framework/ for the canonical source repository
11
 *
12
 * @copyright (c) 2015.  KNUT7  Software Technologies AO Inc. (https://marciozebedeu.com/)
13
 * @license   https://marciozebedeu.com/license/new-bsd New BSD License
14
 * @author    Marcio Zebedeu - [email protected]
15
 *
16
 * @version   1.0.2
17
 */
18
19
namespace Ballybran\Helpers\Security;
20
21
use Closure;
22
use Ballybran\Exception\KException;
23
24
class RenderFiles
25
{
26
    protected $index = 'index';
27
    protected $header = 'header';
28
    protected $footer = 'footer';
29
    protected $ex = '.phtml';
30
31
    public function __construct()
32
    {
33
        $this->ex;
34
    }
35
36
    protected function isViewPath($controller)
37
    {
38
        if (!file_exists(VIEW) || !is_readable(VIEW)) {
39
            return KException::noPathView();
0 ignored issues
show
Bug introduced by
Are you sure the usage of Ballybran\Exception\KException::noPathView() targeting Ballybran\Exception\KException::noPathView() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
40
        }
41
42
        if (!is_readable(VIEW . $controller) || !file_exists(VIEW . $controller)) {
43
            return KException::noPathinView($controller);
0 ignored issues
show
Bug introduced by
Are you sure the usage of Ballybran\Exception\KExc...PathinView($controller) targeting Ballybran\Exception\KException::noPathinView() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
44
        }
45
    }
46
47
    protected function isHeader()
48
    {
49
        if (!file_exists(VIEW . $this->header . $this->ex) || !is_readable(VIEW . $this->header . $this->ex)) {
50
            return KException::notHeader();
0 ignored issues
show
Bug introduced by
Are you sure the usage of Ballybran\Exception\KException::notHeader() targeting Ballybran\Exception\KException::notHeader() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
51
        }
52
        require_once VIEW . $this->header . $this->ex;
53
    }
54
55
    protected function isFooter()
56
    {
57
        if (!is_readable(VIEW . $this->footer . $this->ex) || !file_exists(VIEW . $this->footer . $this->ex)) {
58
            return KException::notFooter();
0 ignored issues
show
Bug introduced by
Are you sure the usage of Ballybran\Exception\KException::notFooter() targeting Ballybran\Exception\KException::notFooter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
59
        }
60
61
        require_once VIEW . $this->footer . $this->ex;
62
    }
63
64
    public function isIndex($controller, $view, $data = null)
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed. ( Ignorable by Annotation )

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

64
    public function isIndex($controller, $view, /** @scrutinizer ignore-unused */ $data = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
65
    {
66
        require_once VIEW . $controller . DS . $view . $this->ex;
67
68
    }
69
}
70