memory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 64
Duplicated Lines 20.31 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 5
Bugs 2 Features 1
Metric Value
c 5
b 2
f 1
dl 13
loc 64
rs 10
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 13 13 1
A run() 0 6 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
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