Completed
Push — v4.0 ( 488a49...f4158b )
by
unknown
01:49
created

TemplateContext   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A layout() 0 8 1
A insert() 0 4 1
1
<?php
2
3
namespace League\Plates;
4
5
class TemplateContext
6
{
7
    private $template;
8
9
    public function __construct(Template $template) {
10
        $this->template = $template;
11
    }
12
13
    public function layout($template_name, $data) {
14
        $layout = new Template($template_name, $data, [
15
            'children' => $this->template,
16
        ]);
17
        $this->template->addContext([
18
            'layout' => $layout
19
        ]);
20
    }
21
22
    public function insert($template_name, $data) {
23
        $child = new Template($template_name, $data);
0 ignored issues
show
Unused Code introduced by
$child is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
24
25
    }
26
}
27