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.

Serve   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 132
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 41
c 2
b 1
f 0
dl 0
loc 132
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A optionHost() 0 3 1
A optionPort() 0 3 1
A execute() 0 45 2
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
21
/**
22
 * Class Make
23
 *
24
 * @package O2System\Reactor\Cli\Commanders
25
 */
26
class Serve extends Commander
27
{
28
    /**
29
     * Make::$commandVersion
30
     *
31
     * Command version.
32
     *
33
     * @var string
34
     */
35
    protected $commandVersion = '1.0.0';
36
37
    /**
38
     * Make::$commandDescription
39
     *
40
     * Command description.
41
     *
42
     * @var string
43
     */
44
    protected $commandDescription = 'CLI_SERVE_DESC';
45
46
    /**
47
     * Make::$commandOptions
48
     *
49
     * Command options.
50
     *
51
     * @var array
52
     */
53
    protected $commandOptions = [
54
        'host' => [
55
            'description' => 'CLI_SERVE_HOST_HELP',
56
            'required'    => false,
57
        ],
58
        'port' => [
59
            'description' => 'CLI_SERVE_PORT_HELP',
60
            'required'    => false,
61
        ],
62
    ];
63
64
    /**
65
     * Serve::$host
66
     *
67
     * Serve host.
68
     *
69
     * @var string
70
     */
71
    protected $optionHost;
72
73
    /**
74
     * Serve::$port
75
     *
76
     * Serve port.
77
     *
78
     * @var int
79
     */
80
    protected $optionPort;
81
82
    // ------------------------------------------------------------------------
83
84
    /**
85
     * Serve::optionHost
86
     * 
87
     * @param string $host
88
     */
89
    public function optionHost($host)
90
    {
91
        $this->optionHost = $host;
92
    }
93
94
    // ------------------------------------------------------------------------
95
96
    /**
97
     * Serve::optionPort
98
     * 
99
     * @param int $port
100
     */
101
    public function optionPort($port)
102
    {
103
        $this->optionPort = $port;
104
    }
105
106
    // ------------------------------------------------------------------------
107
108
    /**
109
     * Serve::execute
110
     * 
111
     * @throws \ReflectionException
112
     */
113
    public function execute()
114
    {
115
        $options = input()->get();
116
117
        if (empty($options)) {
118
            $_GET[ 'host' ] = 'localhost';
119
            $_GET[ 'port' ] = 2107;
120
        }
121
122
        $this->__callOptions();
123
124
        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

124
        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...
125
            (new Format())
126
                ->setContextualClass(Format::SUCCESS)
127
                ->setString(language()->getLine('CLI_SERVE_STARTED', [$this->optionHost, $this->optionPort]))
128
                ->setNewLinesAfter(1)
129
        );
130
131
        $_SERVER[ 'DOCUMENT_ROOT' ] = PATH_PUBLIC;
132
133
        output()->write(
134
            (new Format())
135
                ->setContextualClass(Format::INFO)
136
                ->setString(language()->getLine('CLI_SERVE_DOC_ROOT', [$_SERVER[ 'DOCUMENT_ROOT' ]]))
137
                ->setNewLinesAfter(1)
138
        );
139
140
        output()->write(
141
            (new Format())
142
                ->setContextualClass(Format::WARNING)
143
                ->setString(language()->getLine('CLI_SERVE_STOP'))
144
                ->setNewLinesAfter(1)
145
        );
146
147
        /*
148
         * Call PHP's built-in webserver, making sure to set our
149
         * base path to the public folder, and to use the rewrite file
150
         * to ensure our environment is set and it simulates basic mod_rewrite.
151
         */
152
        passthru('php -S ' .
153
            $this->optionHost .
154
            ':' .
155
            $this->optionPort .
156
            ' -t ' .
157
            str_replace('\\', DIRECTORY_SEPARATOR, DIR_PUBLIC) . ' ' . PATH_ROOT . 'server.php'
0 ignored issues
show
Bug introduced by
The constant O2System\Reactor\Cli\Commanders\PATH_ROOT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant O2System\Reactor\Cli\Commanders\DIR_PUBLIC was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
158
        );
159
    }
160
}