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

ResolveNameArgs::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 3
dl 0
loc 5
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates\Template;
4
5
class ResolveNameArgs
6
{
7
    public $name;
8
    public $context;
9
    private $resolve_name;
10
11 140
    public function __construct($name, array $context, callable $resolve_name) {
12 140
        $this->name = $name;
13 140
        $this->context = $context;
14 140
        $this->resolve_name = $resolve_name;
15 140
    }
16
17 24
    public function withName($name) {
18 24
        return new self($name, $this->context, $this->resolve_name);
19
    }
20
21 8
    public function withContext(array $context) {
22 8
        return new self($this->name, $context, $this->resolve_name);
23
    }
24
25
    public function resolveName($name = null, array $context = []) {
26
        return new self($name ?: $this->name, $context ?: $this->context, $this->resolve_name);
27
    }
28
}
29