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.

Registry   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 156
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 67
c 1
b 0
f 0
dl 0
loc 156
rs 10
wmc 14

4 Methods

Rating   Name   Duplication   Size   Complexity  
A optionFlush() 0 19 4
A optionMetadata() 0 17 5
A optionInfo() 0 26 1
A optionUpdate() 0 18 4
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;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Kernel\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\Reactor\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
73
    /**
74
     * Registry::optionUpdate
75
     * 
76
     * @param string|null $type
77
     */
78
    public function optionUpdate($type = null)
79
    {
80
        if (in_array($type, ['modules', 'languages'])) {
81
            switch ($type) {
82
                case 'modules':
83
                    modules()->updateRegistry();
0 ignored issues
show
Bug introduced by
The function modules was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

83
                    /** @scrutinizer ignore-call */ 
84
                    modules()->updateRegistry();
Loading history...
84
                    break;
85
86
                case 'languages':
87
                    language()->updateRegistry();
0 ignored issues
show
Bug introduced by
The method updateRegistry() does not exist on O2System\Kernel\Services\Language. ( Ignorable by Annotation )

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

87
                    language()->/** @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...
88
                    break;
89
            }
90
        } else {
91
            modules()->updateRegistry();
92
            language()->updateRegistry();
93
        }
94
95
        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...
96
    }
97
98
    // ------------------------------------------------------------------------
99
100
    /**
101
     * Registry::optionFlush
102
     * 
103
     * @param string|null $type
104
     */
105
    public function optionFlush($type = null)
106
    {
107
        if (in_array($type, ['modules', 'languages'])) {
108
            switch ($type) {
109
                case 'modules':
110
                    modules()->flushRegistry();
0 ignored issues
show
Bug introduced by
The function modules was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

110
                    /** @scrutinizer ignore-call */ 
111
                    modules()->flushRegistry();
Loading history...
111
                    break;
112
113
                case 'languages':
114
                    language()->flushRegistry();
0 ignored issues
show
Bug introduced by
The method flushRegistry() does not exist on O2System\Kernel\Services\Language. ( Ignorable by Annotation )

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

114
                    language()->/** @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...
115
                    break;
116
            }
117
118
        } else {
119
            modules()->flushRegistry();
120
            language()->flushRegistry();
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::optionInfo
130
     */
131
    public function optionInfo()
132
    {
133
        $table = new Table();
134
135
        $table
136
            ->addHeader('Metadata')
137
            ->addHeader('Total');
138
139
        $table
140
            ->addRow()
141
            ->addColumn('Modules')
142
            ->addColumn(modules()->getTotalRegistry());
0 ignored issues
show
Bug introduced by
The function modules was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

142
            ->addColumn(/** @scrutinizer ignore-call */ modules()->getTotalRegistry());
Loading history...
143
144
        $table
145
            ->addRow()
146
            ->addColumn('Language')
147
            ->addColumn(language()->getTotalRegistry());
0 ignored issues
show
Bug introduced by
The method getTotalRegistry() does not exist on O2System\Kernel\Services\Language. ( Ignorable by Annotation )

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

147
            ->addColumn(language()->/** @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...
148
149
        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

149
        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...
150
            (new Format())
151
                ->setString($table->render())
152
                ->setNewLinesBefore(1)
153
                ->setNewLinesAfter(2)
154
        );
155
156
        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...
157
    }
158
159
    // ------------------------------------------------------------------------
160
161
    /**
162
     * Registry::optionMetadata
163
     * 
164
     * @param string $type
165
     */
166
    public function optionMetadata($type)
167
    {
168
        if (in_array($type, ['modules', 'languages'])) {
169
            switch ($type) {
170
                case 'modules':
171
                    $line = PHP_EOL . print_r(modules()->getRegistry(), true);
0 ignored issues
show
Bug introduced by
The function modules was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

171
                    $line = PHP_EOL . print_r(/** @scrutinizer ignore-call */ modules()->getRegistry(), true);
Loading history...
172
                    break;
173
174
                case 'languages':
175
                    $line = PHP_EOL . print_r(language()->getRegistry(), true);
0 ignored issues
show
Bug introduced by
The method getRegistry() does not exist on O2System\Kernel\Services\Language. ( Ignorable by Annotation )

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

175
                    $line = PHP_EOL . print_r(language()->/** @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...
176
                    break;
177
            }
178
179
            if (isset($line)) {
180
                output()->write($line);
181
182
                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...
183
            }
184
        }
185
    }
186
}