Phiew   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A with() 0 6 1
A render() 0 5 1
1
<?php
2
namespace Wandu\View;
3
4
use Wandu\View\Contracts\RenderInterface;
5
use Wandu\View\Phiew\Contracts\ResolverInterface;
6
7
class Phiew implements RenderInterface
8
{
9
    /** @var \Wandu\View\Phiew\Contracts\ResolverInterface */
10
    protected $resolver;
11
12
    /** @var array */
13
    protected $attributes = [];
14
    
15 4
    public function __construct(ResolverInterface $resolver)
16
    {
17 4
        $this->resolver = $resolver;
18 4
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23 1
    public function with(array $attributes = [])
24
    {
25 1
        $new = clone $this;
26 1
        $new->attributes = array_merge($new->attributes, $attributes);
27 1
        return $new;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 4
    public function render($template, array $attributes = [], $basePath = null)
34
    {
35 4
        $template = $this->resolver->resolve($template);
36 4
        return $template->execute($attributes + $this->attributes);
37
    }
38
}
39