Pool   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 71
Duplicated Lines 76.06 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 54
loc 71
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A onConfigUpdated() 10 10 3
A getConfigDefaults() 42 43 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace PHPDaemon\Servers\FastCGI;
3
4
use PHPDaemon\Config\Entry\Size;
5
use PHPDaemon\Config\Entry\Time;
6
7
/**
8
 * @package    NetworkServers
9
 * @subpackage Base
10
 * @author     Vasily Zorin <[email protected]>
11
 */
12
class Pool extends \PHPDaemon\Network\Server
13
{
14
    /**
15
     * @var string "GPC" Variables order
16
     */
17
    public $variablesOrder;
18
19
    /**
20
     * Called when worker is going to update configuration
21
     * @return void
22
     */
23 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...
24
    {
25
        parent::onConfigUpdated();
26
27
        if (($order = ini_get('request_order')) || ($order = ini_get('variables_order'))) {
28
            $this->variablesOrder = $order;
29
        } else {
30
            $this->variablesOrder = null;
31
        }
32
    }
33
34
    /**
35
     * Setting default config options
36
     * Overriden from ConnectionPool::getConfigDefaults
37
     * @return array|bool
38
     */
39 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...
40
    {
41
        return [
42
            /* [string|array] Listen addresses */
43
            'listen' => 'tcp://127.0.0.1,unix:///tmp/phpdaemon.fcgi.sock',
44
45
            /* [integer] Listen port */
46
            'port' => 9000,
47
48
            /* [boolean] Read request body from the file given in REQUEST_BODY_FILE parameter */
49
            'auto-read-body-file' => 1,
50
51
            /* [string] Allowed clients ip list */
52
            'allowed-clients' => '127.0.0.1',
53
54
            /* [boolean] Enable X-Sendfile? */
55
            'send-file' => 0,
56
57
            /* [string] Directory for X-Sendfile */
58
            'send-file-dir' => '/dev/shm',
59
60
            /* [string] Prefix for files used for X-Sendfile */
61
            'send-file-prefix' => 'fcgi-',
62
63
            /* [boolean] Use X-Sendfile only if server['USE_SENDFILE'] provided. */
64
            'send-file-onlybycommand' => 0,
65
66
            /* [boolean] Expose PHPDaemon version by X-Powered-By Header */
67
            'expose' => 1,
68
69
            /* [Time] Keepalive time */
70
            'keepalive' => new Time('0s'),
71
72
            /* [Size] Chunk size */
73
            'chunksize' => new Size('8k'),
74
75
            /* [string] Default charset */
76
            'defaultcharset' => 'utf-8',
77
78
            /* [Size] Maximum uploading file size. */
79
            'upload-max-size' => new Size(ini_get('upload_max_filesize')),
80
        ];
81
    }
82
}
83