Completed
Push — v4.0-dev ( 6660e2...b14a8f )
by
unknown
11s
created

ResolveDataArgs::resolveData()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 2
nc 1
nop 2
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates\Template;
4
5
class ResolveDataArgs
6
{
7
    public $data;
8
    public $context;
9
    private $resolve_data;
10
11
    public function __construct(array $data, array $context, $resolve_data) {
12
        $this->data = $data;
13
        $this->context = $context;
14
        $this->resolve_data = $resolve_data;
15
    }
16
17
    public function withData($data) {
18
        return new self($data, $this->context, $this->resolve_name);
0 ignored issues
show
Bug introduced by
The property resolve_name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
19
    }
20
21
    public function withContext(array $context) {
22
        return new self($this->data, $context, $this->resolve_name);
23
    }
24
25
    public function resolveData($data = null, array $context = []) {
26
        return new self($data ?: $this->data, $context ?: $this->context, $this->resolve_data);
27
    }
28
}
29