Completed
Push — v4.0 ( 3a8f05...488a49 )
by
unknown
03:09
created

Template::withName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates;
4
5
/** Template value object */
6
class Template
7
{
8
    private $name;
9
    private $data;
10
    private $context;
11
    private $content;
12
13
    public function __construct(
14
        $name,
15
        array $data = [],
16
        array $context = [],
17
        Content $content = null
18
    ) {
19
        $this->name = $name;
20
        $this->data = $data;
21
        $this->context = $context;
22
        $this->content = $content ?: Content\StringContent::empty();
23
    }
24
25
    public function getName() {
26
        return $this->name;
27
    }
28
29
    public function getData() {
30
        return $this->data;
31
    }
32
33
    public function getContext() {
34
        return $this->context;
35
    }
36
37
    public function getContent() {
38
        return $this->content;
39
    }
40
41
    public function withName($name) {
42
        return new self($name, $this->data, $this->context, $this->content);
43
    }
44
45
    public function withData(array $data) {
46
        return new self($this->name, $data, $this->context, $this->content);
47
    }
48
49
    public function withContext(array $context) {
50
        return new self($this->name, $this->data, $context, $this->content);
51
    }
52
53
    public function withContent(Content $content) {
54
        return new self($this->name, $this->data, $this->context, $content);
55
    }
56
}
57