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 ( 86dce3...98cf71 )
by Nur
02:40
created

Registry::optionInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
nc 1
nop 0
dl 0
loc 26
rs 9.6666
c 0
b 0
f 0
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
    public function optionUpdate($type = null)
72
    {
73
        if (in_array($type, ['modules', 'languages'])) {
74
            switch ($type) {
75
                case 'modules':
76
                    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

76
                    /** @scrutinizer ignore-call */ 
77
                    modules()->updateRegistry();
Loading history...
77
                    break;
78
79
                case 'languages':
80
                    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

80
                    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...
81
                    break;
82
            }
83
        } else {
84
            modules()->updateRegistry();
85
            language()->updateRegistry();
86
        }
87
88
        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...
89
    }
90
91
    public function optionFlush($type = null)
92
    {
93
        if (in_array($type, ['modules', 'languages'])) {
94
            switch ($type) {
95
                case 'modules':
96
                    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

96
                    /** @scrutinizer ignore-call */ 
97
                    modules()->flushRegistry();
Loading history...
97
                    break;
98
99
                case 'languages':
100
                    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

100
                    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...
101
                    break;
102
            }
103
104
        } else {
105
            modules()->flushRegistry();
106
            language()->flushRegistry();
107
        }
108
109
        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...
110
    }
111
112
    public function optionInfo()
113
    {
114
        $table = new Table();
115
116
        $table
117
            ->addHeader('Metadata')
118
            ->addHeader('Total');
119
120
        $table
121
            ->addRow()
122
            ->addColumn('Modules')
123
            ->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

123
            ->addColumn(/** @scrutinizer ignore-call */ modules()->getTotalRegistry());
Loading history...
124
125
        $table
126
            ->addRow()
127
            ->addColumn('Language')
128
            ->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

128
            ->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...
129
130
        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

130
        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...
131
            (new Format())
132
                ->setString($table->render())
133
                ->setNewLinesBefore(1)
134
                ->setNewLinesAfter(2)
135
        );
136
137
        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...
138
    }
139
140
    public function optionMetadata($type)
141
    {
142
        if (in_array($type, ['modules', 'languages'])) {
143
            switch ($type) {
144
                case 'modules':
145
                    $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

145
                    $line = PHP_EOL . print_r(/** @scrutinizer ignore-call */ modules()->getRegistry(), true);
Loading history...
146
                    break;
147
148
                case 'languages':
149
                    $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

149
                    $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...
150
                    break;
151
            }
152
153
            if (isset($line)) {
154
                output()->write($line);
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
}