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 (#2062)
by
unknown
02:12
created

Initializer::getTemplate()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 44

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
nc 4
nop 5
dl 0
loc 44
ccs 0
cts 32
cp 0
crap 12
rs 9.216
c 0
b 0
f 0
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\Component\Initializer;
9
10
class Initializer
11
{
12
    public function getRecipes()
13
    {
14
        $recipes = [];
15
        $dir = new \DirectoryIterator(__DIR__ . '/../../../recipe');
16
        foreach ($dir as $fileinfo) {
17
            if ($fileinfo->isDot()) {
18
                continue;
19
            }
20
            if ($fileinfo->isDir()) {
21
                continue;
22
            }
23
24
            $recipe = pathinfo($fileinfo->getFilename(), PATHINFO_FILENAME);
25
26
            if ($recipe === 'README') {
27
                continue;
28
            }
29
30
            $recipes[] = $recipe;
31
        }
32
33
        sort($recipes);
34
        return $recipes;
35
    }
36
37
    public function getTemplate(string $template, string $project, string $repository, array $hosts, bool $allow): string
38
    {
39
        $h = "";
40
        foreach ($hosts as $host) {
41
            $h .= "host('{$host}');\n";
42
        }
43
44
        $dontTrack = $allow ? '' : "define('DONT_TRACK', 'ಠ_ಠ');\n";
45
46
        return <<<PHP
47
<?php
48
namespace Deployer;
49
{$dontTrack}
50
require 'recipe/$template.php';
51
52
// Config
53
54
set('application', '{$project}');
55
set('deploy_path', '~/{{application}}');
56
set('repository', '{$repository}');
57
58
add('shared_files', []);
59
add('shared_dirs', []);
60
add('writable_dirs', []);
61
62
// Hosts
63
64
{$h}
65
66
// Tasks
67
68
task('build', function () {
69
    run('cd {{release_path}} && npm run build');
70
});
71
72
task('build:upload', function () {
73
    upload('dist', '{{release_path}}/dist');
74
});
75
76
// If deploy fails automatically unlock.
77
after('deploy:failed', 'deploy:unlock');
78
79
PHP;
80
    }
81
}
82