memory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 13
Ratio 100 %

Importance

Changes 5
Bugs 2 Features 1
Metric Value
cc 1
eloc 11
c 5
b 2
f 1
nc 1
nop 10
dl 13
loc 13
rs 9.4285

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace Sovereign\Plugins\onTimer;
4
5
use Discord\Discord;
6
use Monolog\Logger;
7
use Sovereign\Lib\Config;
8
use Sovereign\Lib\cURL;
9
use Sovereign\Lib\Db;
10
use Sovereign\Lib\Permissions;
11
use Sovereign\Lib\ServerConfig;
12
use Sovereign\Lib\Settings;
13
use Sovereign\Lib\Users;
14
15
class memory extends \Threaded implements \Collectable
16
{
17
    /**
18
     * @var Discord
19
     */
20
    protected $discord;
21
    /**
22
     * @var Logger
23
     */
24
    protected $log;
25
    /**
26
     * @var Config
27
     */
28
    protected $config;
29
    /**
30
     * @var Db
31
     */
32
    protected $db;
33
    /**
34
     * @var cURL
35
     */
36
    protected $curl;
37
    /**
38
     * @var Settings
39
     */
40
    protected $settings;
41
    /**
42
     * @var Permissions
43
     */
44
    protected $permissions;
45
    /**
46
     * @var ServerConfig
47
     */
48
    protected $serverConfig;
49
    /**
50
     * @var Users
51
     */
52
    protected $users;
53
    /**
54
     * @var array
55
     */
56
    protected $extras;
57
58 View Code Duplication
    public function __construct($discord, $log, $config, $db, $curl, $settings, $permissions, $serverConfig, $users, $extras)
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...
59
    {
60
        $this->discord = $discord;
61
        $this->log = $log;
62
        $this->config = $config;
63
        $this->db = $db;
64
        $this->curl = $curl;
65
        $this->settings = $settings;
66
        $this->permissions = $permissions;
67
        $this->serverConfig = $serverConfig;
68
        $this->users = $users;
69
        $this->extras = $extras;
70
    }
71
72
    public function run()
73
    {
74
        $this->log->addInfo("Memory in use before garbage collection: " . memory_get_usage() / 1024 / 1024 . "MB");
75
        gc_collect_cycles();
76
        $this->log->addInfo("Memory in use after garbage collection: " . memory_get_usage() / 1024 / 1024 . "MB");
77
    }
78
}
79