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
Push — master ( 9449cf...4032bb )
by Steeven
02:31
created

Registry::optionModules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the O2System 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\Framework\Cli\Commanders;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Framework\Cli\Commander;
19
use O2System\Kernel\Cli\Writers\Format;
20
use O2System\Kernel\Cli\Writers\Table;
21
22
/**
23
 * Class Registry
24
 *
25
 * @package O2System\Framework\Cli\Commanders
26
 */
27
class Registry extends Commander
28
{
29
    /**
30
     * Make::$commandVersion
31
     *
32
     * Command version.
33
     *
34
     * @var string
35
     */
36
    protected $commandVersion = '1.0.0';
37
38
    /**
39
     * Make::$commandDescription
40
     *
41
     * Command description.
42
     *
43
     * @var string
44
     */
45
    protected $commandDescription = 'CLI_REGISTRY_DESC';
46
47
    /**
48
     * Make::$commandOptions
49
     *
50
     * Command options.
51
     *
52
     * @var array
53
     */
54
    protected $commandOptions = [
55
        'update'   => [
56
            'description' => 'CLI_REGISTRY_UPDATE_DESC',
57
            'help'        => 'CLI_REGISTRY_UPDATE_HELP',
58
        ],
59
        'flush'    => [
60
            'description' => 'CLI_REGISTRY_FLUSH_DESC',
61
        ],
62
        'info'     => [
63
            'description' => 'CLI_REGISTRY_INFO_DESC',
64
        ],
65
        'metadata' => [
66
            'description' => 'CLI_REGISTRY_METADATA_DESC',
67
            'help'        => 'CLI_REGISTRY_METADATA_HELP',
68
        ],
69
    ];
70
71
    /**
72
     * Registry::$optionModules
73
     *
74
     * @var bool
75
     */
76
    protected $optionModules = false;
77
78
    /**
79
     * Registry::$optionLanguages
80
     *
81
     * @var bool
82
     */
83
    protected $optionLanguages = false;
84
85
    // ------------------------------------------------------------------------
86
87
    /**
88
     * Registry::optionModules
89
     */
90
    public function optionModules()
91
    {
92
        $this->optionModules = true;
93
    }
94
95
    // ------------------------------------------------------------------------
96
97
    /**
98
     * Registry::optionLanguages
99
     */
100
    public function optionLanguages()
101
    {
102
        $this->optionLanguages = true;
103
    }
104
105
    // ------------------------------------------------------------------------
106
107
    /**
108
     * Registry::update
109
     *
110
     * @throws \Exception
111
     */
112
    public function update()
113
    {
114
        if($this->optionModules) {
115
            modules()->updateRegistry();
0 ignored issues
show
Bug introduced by
The method updateRegistry() does not exist on O2System\Framework\Conta...s\DataStructures\Module. ( Ignorable by Annotation )

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

115
            modules()->/** @scrutinizer ignore-call */ updateRegistry();

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...
116
        } elseif($this->optionLanguages) {
117
            language()->updateRegistry();
0 ignored issues
show
introduced by
The method updateRegistry() does not exist on O2System\Kernel\Services\Language. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

117
            language()->/** @scrutinizer ignore-call */ updateRegistry();
Loading history...
118
        } else {
119
            modules()->updateRegistry();
120
            language()->updateRegistry();
121
        }
122
123
        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...
124
    }
125
126
    // ------------------------------------------------------------------------
127
128
    /**
129
     * Registry::flush
130
     *
131
     * @throws \Psr\Cache\InvalidArgumentException
132
     */
133
    public function flush()
134
    {
135
        if($this->optionModules) {
136
            modules()->flushRegistry();
0 ignored issues
show
Bug introduced by
The method flushRegistry() does not exist on O2System\Framework\Conta...s\DataStructures\Module. ( Ignorable by Annotation )

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

136
            modules()->/** @scrutinizer ignore-call */ flushRegistry();

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...
137
        } elseif($this->optionLanguages) {
138
            language()->flushRegistry();
0 ignored issues
show
introduced by
The method flushRegistry() does not exist on O2System\Kernel\Services\Language. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

138
            language()->/** @scrutinizer ignore-call */ flushRegistry();
Loading history...
139
        } else {
140
            modules()->flushRegistry();
141
            language()->flushRegistry();
142
        }
143
144
        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...
145
    }
146
147
    // ------------------------------------------------------------------------
148
149
    /**
150
     * Registry::info
151
     */
152
    public function info()
153
    {
154
        $table = new Table();
155
156
        $table
157
            ->addHeader('Metadata')
158
            ->addHeader('Total');
159
160
        $table
161
            ->addRow()
162
            ->addColumn('Modules')
163
            ->addColumn(modules()->getTotalRegistry());
0 ignored issues
show
Bug introduced by
The method getTotalRegistry() does not exist on O2System\Framework\Conta...s\DataStructures\Module. ( Ignorable by Annotation )

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

163
            ->addColumn(modules()->/** @scrutinizer ignore-call */ getTotalRegistry());

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...
164
165
        $table
166
            ->addRow()
167
            ->addColumn('Language')
168
            ->addColumn(language()->getTotalRegistry());
0 ignored issues
show
introduced by
The method getTotalRegistry() does not exist on O2System\Kernel\Services\Language. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

168
            ->addColumn(language()->/** @scrutinizer ignore-call */ getTotalRegistry());
Loading history...
169
170
        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

170
        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...
171
            (new Format())
172
                ->setString($table->render())
173
                ->setNewLinesBefore(1)
174
                ->setNewLinesAfter(2)
175
        );
176
177
        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...
178
    }
179
180
    // ------------------------------------------------------------------------
181
182
    /**
183
     * Registry::metadata
184
     */
185
    public function metadata()
186
    {
187
        if($this->optionModules) {
188
            $line = PHP_EOL . print_r(modules()->getRegistry(), true);
0 ignored issues
show
Bug introduced by
The method getRegistry() does not exist on O2System\Framework\Conta...s\DataStructures\Module. ( Ignorable by Annotation )

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

188
            $line = PHP_EOL . print_r(modules()->/** @scrutinizer ignore-call */ getRegistry(), true);

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...
189
        } elseif($this->optionLanguages) {
190
            $line = PHP_EOL . print_r(language()->getRegistry(), true);
0 ignored issues
show
introduced by
The method getRegistry() does not exist on O2System\Kernel\Services\Language. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

190
            $line = PHP_EOL . print_r(language()->/** @scrutinizer ignore-call */ getRegistry(), true);
Loading history...
191
        } else {
192
            $line = PHP_EOL . print_r(modules()->getRegistry(), true);
193
            $line.= PHP_EOL . print_r(language()->getRegistry(), true);
194
        }
195
196
        if (isset($line)) {
197
            output()->write($line);
198
199
            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...
200
        }
201
    }
202
}