Pool::getConfigDefaults()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 46

Duplication

Lines 45
Ratio 97.83 %

Importance

Changes 0
Metric Value
cc 1
dl 45
loc 46
rs 9.1781
c 0
b 0
f 0
nc 1
nop 0
1
<?php
2
namespace PHPDaemon\Servers\HTTP;
3
4
use PHPDaemon\Config\Entry\Size;
5
use PHPDaemon\Config\Entry\Time;
6
7
/**
8
 * @package    NetworkServer
9
 * @subpackage HTTPServer
10
 * @author     Vasily Zorin <[email protected]>
11
 */
12
class Pool extends \PHPDaemon\Network\Server
13
{
14
    /**
15
     * @var string Variables order "GPC"
16
     */
17
    public $variablesOrder;
18
19
    /**
20
     * @var WebSocketServer WebSocketServer instance
21
     */
22
    public $WS;
23
24
    /**
25
     * Called when worker is going to update configuration.
26
     * @return void
27
     */
28 View Code Duplication
    public function onConfigUpdated()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        parent::onConfigUpdated();
31
32
        if (($order = ini_get('request_order')) || ($order = ini_get('variables_order'))) {
33
            $this->variablesOrder = $order;
34
        } else {
35
            $this->variablesOrder = null;
36
        }
37
    }
38
39
    /**
40
     * Called when the worker is ready to go.
41
     * @return void
42
     */
43
    public function onReady()
44
    {
45
        parent::onReady();
46
        $this->WS = \PHPDaemon\Servers\WebSocket\Pool::getInstance($this->config->wssname->value, false);
0 ignored issues
show
Bug introduced by
The property wssname does not seem to exist in PHPDaemon\Config\Section.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
Documentation Bug introduced by
It seems like \PHPDaemon\Servers\WebSo...>wssname->value, false) of type object<PHPDaemon\Network\this> is incompatible with the declared type object<PHPDaemon\Servers\HTTP\WebSocketServer> of property $WS.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
47
    }
48
49
    /**
50
     * Setting default config options
51
     * Overriden from AppInstance::getConfigDefaults
52
     * @return array|bool
53
     */
54 View Code Duplication
    protected function getConfigDefaults()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
55
    {
56
        return [
57
            /* [string|array] Listen addresses */
58
            'listen' => 'tcp://0.0.0.0',
59
60
            /* [integer] Listen port */
61
            'port' => 80,
62
63
            /* [boolean] Enable X-Sendfile? */
64
            'send-file' => 0,
65
66
            /* [string] Directory for X-Sendfile */
67
            'send-file-dir' => '/dev/shm',
68
69
            /* [string] Prefix for files used for X-Sendfile */
70
            'send-file-prefix' => 'http-',
71
72
            /* [boolean] Use X-Sendfile only if server['USE_SENDFILE'] provided. */
73
            'send-file-onlybycommand' => 0,
74
75
            /* [boolean] Expose PHPDaemon version by X-Powered-By Header */
76
            'expose' => 1,
77
78
            /* [Time] Keepalive time */
79
            'keepalive' => new Time('0s'),
80
81
            /* [Size] Chunk size */
82
            'chunksize' => new Size('8k'),
83
84
            /* [string] Default charset */
85
            'defaultcharset' => 'utf-8',
86
87
            /* [string] Related WebSocketServer instance name */
88
            'wss-name' => '',
89
90
            /* [string] Related FlashPolicyServer instance name */
91
            'fps-name' => '',
92
93
            /* [Size] Maximum uploading file size. */
94
            'upload-max-size' => new Size(ini_get('upload_max_filesize')),
95
96
            /* [string] Reponder application (if you do not want to use AppResolver) */
97
            'responder' => null,
98
        ];
99
    }
100
}
101