GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Engine   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 12 3
1
<?php
2
/*
3
 * This file is part of StringTemplate.
4
 *
5
 * (c) 2013 Nicolò Martini
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace StringTemplate;
12
13
/**
14
 * Class Engine
15
 *
16
 * Replace placeholder in strings with nested (array) values.
17
 *
18
 * Example:
19
 * <code>
20
 * $engine->render('This is {a} and these are {c.0} and {c.1}', ['a' => 'b', 'c' => ['d', 'e']]);
21
 * //Prints "This is b and these are d and e"
22
 * </code>
23
 */
24
class Engine extends AbstractEngine
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function render($template, $value)
30
    {
31
        $result = $template;
32
        if (!is_array($value))
33
            $value = array('' => $value);
34
35
        foreach (new NestedKeyIterator(new RecursiveArrayOnlyIterator($value)) as $key => $value) {
36
            $result = str_replace($this->left . $key . $this->right, $value, $result);
37
        }
38
39
        return $result;
40
    }
41
}