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

Serve::optionHost()   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 1
dl 0
loc 3
rs 10
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
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
    public function optionHost($host)
83
    {
84
        $this->optionHost = $host;
85
    }
86
87
    public function optionPort($port)
88
    {
89
        $this->optionPort = $port;
90
    }
91
92
    public function execute()
93
    {
94
        $options = input()->get();
95
96
        if (empty($options)) {
97
            $_GET[ 'host' ] = 'localhost';
98
            $_GET[ 'port' ] = 8000;
99
        }
100
101
        parent::execute();
102
103
        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

103
        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...
104
            (new Format())
105
                ->setContextualClass(Format::SUCCESS)
106
                ->setString(language()->getLine('CLI_SERVE_STARTED', [$this->optionHost, $this->optionPort]))
107
                ->setNewLinesAfter(1)
108
        );
109
110
        $_SERVER[ 'DOCUMENT_ROOT' ] = PATH_PUBLIC;
111
112
        output()->write(
113
            (new Format())
114
                ->setContextualClass(Format::INFO)
115
                ->setString(language()->getLine('CLI_SERVE_DOC_ROOT', [$_SERVER[ 'DOCUMENT_ROOT' ]]))
116
                ->setNewLinesAfter(1)
117
        );
118
119
        output()->write(
120
            (new Format())
121
                ->setContextualClass(Format::WARNING)
122
                ->setString(language()->getLine('CLI_SERVE_STOP'))
123
                ->setNewLinesAfter(1)
124
        );
125
126
        /*
127
         * Call PHP's built-in webserver, making sure to set our
128
         * base path to the public folder, and to use the rewrite file
129
         * to ensure our environment is set and it simulates basic mod_rewrite.
130
         */
131
        passthru('php -S ' .
132
            $this->optionHost .
133
            ':' .
134
            $this->optionPort .
135
            ' -t ' .
136
            str_replace('\\', DIRECTORY_SEPARATOR, DIR_PUBLIC) . ' ' . PATH_ROOT . 'server.php'
0 ignored issues
show
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...
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...
137
        );
138
    }
139
}