View   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A renderMustache() 0 7 1
A getView() 0 5 1
1
<?php
2
/**
3
 * View
4
 *
5
 * @package     erdiko/core
6
 * @copyright   2012-2017 Arroyo Labs, Inc. http://www.arroyolabs.com
7
 * @author      John Arroyo <[email protected]>
8
 */
9
namespace erdiko\core;
10
11
12
class View extends Container
13
{
14
    protected $_config = null;
15
16
    /**
17
     * Constructor
18
     * @param string $template
19
     * @param mixed $data
20
     * @param string $templateFolder
0 ignored issues
show
Documentation introduced by
There is no parameter named $templateFolder. Did you maybe mean $template?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
21
     */
22
    public function __construct($template = null, $data = null, $templateRootFolder = ERDIKO_APP)
23
    {
24
        $this->initiate($template, $data, $templateRootFolder);
25
        $this->setTemplateFolder('views');
26
    }
27
28
    /**
29
     * Attach getView function to the mustache view
30
     */
31
    public function renderMustache($filename, $data) {
32
        // This is for mustache compatibility
33
        $data['getView'] = function($name, $data) { 
34
            return $this->getView($name, $data); 
35
            };
36
        return parent::renderMustache($filename, $data);
37
    }
38
39
    /**
40
     * Get a view, for nesting views
41
     * This is a convenience wrapper for inherited getTemplateFile() method
42
     * Notes: expects this sub view to be in the same views folder (or nested below this folder relative to views/).
43
     * 
44
     */
45
    public function getView($filename, $data = null)
46
    {
47
        // $data = ($data === null) ? $this->_data : $data;
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
48
        return $this->getTemplateFile($this->getTemplateFolder().$filename, $data);
49
    }
50
}
51