Completed
Push — 186-data ( d4ee1e...572d68 )
by
unknown
10:31 queued 08:00
created

CallableHydrateTemplate::resolvePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates\HydrateTemplate;
4
5
use League\Plates;
6
7
/** Wraps a callable into the HydrateTemplate interface */
8
class CallableHydrateTemplate implements Plates\HydrateTemplate
9
{
10
    private $hydrate_template;
11
12
    public function __construct(callable $hydrate_template) {
13
        $this->hydrate_template = $hydrate_template;
14
    }
15
16
    public function hydrateTemplate(Plates\Template $template) {
17
        return ($this->hydrate_template)($template);
18
    }
19
20
    public static function stub() {
21
        return new self(function(Plates\Template $template) {});
0 ignored issues
show
Unused Code introduced by
The parameter $template is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    }
23
24
    public static function resolvePath(callable $resolvePath) {
25
        return new self(function($template) use ($resolvePath) {
26
            Plates\Template\setPath(
27
                $template,
28
                $resolvePath(Plates\Template\ResolvePathArgs::fromTemplate($template))
29
            );
30
        });
31
    }
32
}
33