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.
Passed
Pull Request — master (#1061)
by Maxim
04:23 queued 01:35
created

Template   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
dl 0
loc 36
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 13 1
getTemplateContent() 0 1 ?
A getParametersForReplace() 0 4 1
1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Initializer\Template;
9
10
/**
11
 * Abstract template for create deployer configuration.
12
 *
13
 * @author Vitaliy Zhuk <[email protected]>
14
 * @author Anton Medvedev <[email protected]>
15
 */
16
abstract class Template implements TemplateInterface
17
{
18
    /**
19
     * {@inheritDoc}
20
     */
21 1
    public function initialize($filePath)
22
    {
23 1
        $content = $this->getTemplateContent();
24
25 1
        $parameters = $this->getParametersForReplace();
26 1
        $replaceParameters = [];
27 1
        array_walk($parameters, function ($value, $key) use (&$replaceParameters) {
28 1
            $replaceParameters['%' . $key . '%'] = $value;
29 1
        });
30 1
        $content = strtr($content, $replaceParameters);
31
32 1
        file_put_contents($filePath, $content);
33 1
    }
34
35
    /**
36
     * Get content of template.
37
     *
38
     * @return string
39
     */
40
    abstract protected function getTemplateContent();
41
42
    /**
43
     * Get parameters for replace in resource
44
     *
45
     * @return array
46
     */
47
    protected function getParametersForReplace()
48
    {
49
        return [];
50
    }
51
}
52