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.

PlaceholderHandler::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
namespace Thunder\Shortcode\Handler;
3
4
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
5
6
/**
7
 * @author Tomasz Kowalczyk <[email protected]>
8
 */
9
final class PlaceholderHandler
10
{
11
    /** @var string */
12
    private $delimiter;
13
14
    /** @param string $delimiter */
15 19
    public function __construct($delimiter = '%')
16
    {
17 19
        $this->delimiter = $delimiter;
18 19
    }
19
20
    /**
21
     * [placeholder value=18]You age is %value%[/placeholder]
22
     *
23
     * @param ShortcodeInterface $shortcode
24
     *
25
     * @return mixed
26
     */
27 2
    public function __invoke(ShortcodeInterface $shortcode)
28
    {
29 2
        $args = $shortcode->getParameters();
30 2
        $delimiter = $this->delimiter;
31
        $keys = array_map(function($key) use($delimiter) { return $delimiter.$key.$delimiter; }, array_keys($args));
32
        /** @var string[] $values */
33 2
        $values = array_values($args);
34
35 2
        return str_replace($keys, $values, (string)$shortcode->getContent());
36
    }
37
}
38