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 (#2037)
by Elan
02:09
created

Initializer   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 72
ccs 0
cts 52
cp 0
rs 10
c 0
b 0
f 0
wmc 8
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRecipes() 0 24 5
A getTemplate() 0 44 3
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