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.

Helper   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 54
c 1
b 0
f 0
dl 0
loc 92
rs 10
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
B execute() 0 74 6
1
<?php
2
/**
3
 * This file is part of the O2System PHP Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Reactor\Cli\Commanders\Make;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Reactor\Cli\Commanders\Make;
19
use O2System\Kernel\Cli\Writers\Format;
20
21
/**
22
 * Class Helper
23
 *
24
 * @package O2System\Reactor\Cli\Commanders\Make
25
 */
26
class Helper extends Make
27
{
28
    /**
29
     * Helper::$commandDescription
30
     *
31
     * Command description.
32
     *
33
     * @var string
34
     */
35
    protected $commandDescription = 'CLI_MAKE_HELPER_DESC';
36
37
    // ------------------------------------------------------------------------
38
39
    /**
40
     * Helper::execute
41
     * 
42
     * @throws \ReflectionException
43
     */
44
    public function execute()
45
    {
46
        $this->__callOptions();
47
48
        if (empty($this->optionFilename)) {
49
            output()->write(
0 ignored issues
show
Bug introduced by
The method write() does not exist on O2System\Kernel\Http\Output. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
            output()->/** @scrutinizer ignore-call */ write(

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50
                (new Format())
51
                    ->setContextualClass(Format::DANGER)
52
                    ->setString(language()->getLine('CLI_MAKE_HELPER_E_FILENAME'))
53
                    ->setNewLinesAfter(1)
54
            );
55
56
            exit(EXIT_ERROR);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
57
        }
58
59
        if (strpos($this->optionPath, 'Helpers') === false) {
60
            $filePath = $this->optionPath . 'Helpers' . DIRECTORY_SEPARATOR . $this->optionFilename;
61
        } else {
62
            $filePath = $this->optionPath . $this->optionFilename;
63
        }
64
65
        if ( ! is_dir(dirname($filePath))) {
66
            mkdir(dirname($filePath), 0777, true);
67
        }
68
69
        if (is_file($filePath)) {
70
            output()->write(
71
                (new Format())
72
                    ->setContextualClass(Format::DANGER)
73
                    ->setString(language()->getLine('CLI_MAKE_HELPER_E_EXISTS', [$filePath]))
74
                    ->setNewLinesAfter(1)
75
            );
76
77
            exit(EXIT_ERROR);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
78
        }
79
80
        $vars[ 'CREATE_DATETIME' ] = date('d/m/Y H:m');
0 ignored issues
show
Comprehensibility Best Practice introduced by
$vars was never initialized. Although not strictly required by PHP, it is generally a good practice to add $vars = array(); before regardless.
Loading history...
81
        $vars[ 'HELPER' ] = underscore(
82
            snakecase(
83
                pathinfo($filePath, PATHINFO_FILENAME)
84
            )
85
        );
86
        $vars[ 'FILEPATH' ] = $filePath;
87
88
        $phpTemplate = <<<PHPTEMPLATE
89
<?php
90
/**
91
 * Created by O2System Reactor File Generator.
92
 * DateTime: CREATE_DATETIME
93
 */
94
95
// ------------------------------------------------------------------------
96
97
if ( ! function_exists( 'HELPER' ) ) {
98
    /**
99
     * HELPER
100
     */
101
    function HELPER() {
102
    }
103
}
104
PHPTEMPLATE;
105
106
        $fileContent = str_replace(array_keys($vars), array_values($vars), $phpTemplate);
107
        file_put_contents($filePath, $fileContent);
108
109
        if (is_file($filePath)) {
110
            output()->write(
111
                (new Format())
112
                    ->setContextualClass(Format::SUCCESS)
113
                    ->setString(language()->getLine('CLI_MAKE_HELPER_S_MAKE', [$filePath]))
114
                    ->setNewLinesAfter(1)
115
            );
116
117
            exit(EXIT_SUCCESS);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
118
        }
119
    }
120
}