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.
Completed
Push — master ( e8b027...c00205 )
by Beñat
09:31
created

Hooks::addFiles()   B

Complexity

Conditions 5
Paths 24

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
rs 8.8571
cc 5
eloc 13
nc 24
nop 0
1
<?php
2
3
/*
4
 * This file is part of the CS library.
5
 *
6
 * Copyright (c) 2015-present LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace LIN3S\CS\Composer;
15
16
use LIN3S\CS\Application;
17
use LIN3S\CS\Checker\EsLint;
18
use LIN3S\CS\Checker\PhpCsFixer;
19
use LIN3S\CS\Checker\Stylelint;
20
use Symfony\Component\Filesystem\Filesystem;
21
22
/**
23
 * @author Beñat Espiña <[email protected]>
24
 */
25
final class Hooks
26
{
27 View Code Duplication
    public static function addHooks() : void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
    {
29
        $hooksDirectory = self::rootDir() . '/.git/hooks';
30
        $fileSystem = new Filesystem();
31
32
        try {
33
            if ($fileSystem->exists($hooksDirectory)) {
34
                $fileSystem->remove($hooksDirectory);
35
            }
36
            $fileSystem->symlink(__DIR__ . '/../Hooks', $hooksDirectory, true);
37
        } catch (\Exception $exception) {
38
            echo sprintf("Something wrong happens during the symlink process: \n%s\n", $exception->getMessage());
39
        }
40
    }
41
42 View Code Duplication
    public static function buildDistFile() : void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        $distFile = self::rootDir() . '/.lin3s_cs.yml.dist';
45
        $fileSystem = new Filesystem();
46
47
        try {
48
            if ($fileSystem->exists($distFile)) {
49
                return;
50
            }
51
            $fileSystem->copy(self::lin3sCsRootDir() . '/.lin3s_cs.yml.dist', $distFile);
52
        } catch (\Exception $exception) {
53
            echo sprintf("Something wrong happens during the touch process: \n%s\n", $exception->getMessage());
54
        }
55
    }
56
57
    public static function addFiles() : void
58
    {
59
        $app = new Application();
60
        $enabled = $app->parameters()['enabled'] ?? [];
61
62
        !in_array('stylelint', $enabled, true) ?: Stylelint::file($app->parameters());
63
        !in_array('eslint', $enabled, true) ?: EsLint::file($app->parameters());
64
        !in_array('phpcsfixer', $enabled, true) ?: PhpCsFixer::file($app->parameters());
65
66
        $editorConfig = self::rootDir() . '/.editorconfig';
67
        $fileSystem = new Filesystem();
68
69
        try {
70
            $fileSystem->remove($editorConfig);
71
            $fileSystem->symlink(self::lin3sCsRootDir() . '/.editorconfig', $editorConfig, true);
72
        } catch (\Exception $exception) {
73
            echo sprintf("Something wrong happens during the symlink process: \n%s\n", $exception->getMessage());
74
        }
75
    }
76
77
    private static function rootDir() : string
78
    {
79
        return __DIR__ . '/../../../../../../..';
80
    }
81
82
    private static function lin3sCsRootDir() : string
83
    {
84
        return __DIR__ . '/../..';
85
    }
86
}
87