Completed
Pull Request — master (#193)
by De Cramer
20:09
created

DumpMemory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A execute() 0 9 2
1
<?php
2
3
namespace eXpansion\Bundle\Acme\ChatCommand;
4
5
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups;
6
use eXpansion\Framework\AdminGroups\Model\AbstractAdminChatCommand;
7
use eXpansion\Framework\Core\Helpers\ChatNotification;
8
use Symfony\Component\Console\Input\InputInterface;
9
10
/**
11
 * Class DumpMemory
12
 *
13
 * @author    de Cramer Oliver<[email protected]>
14
 * @copyright 2018 Smile
15
 * @package eXpansion\Bundle\Acme\ChatCommand
16
 */
17
class DumpMemory extends AbstractAdminChatCommand
18
{
19
    /**
20
     * @var ChatNotification
21
     */
22
    protected $chatNotification;
23
24
    /**
25
     * DumpMemory constructor.
26
     *
27
     * @param $command
28
     * @param string $permission
29
     * @param array $aliases
30
     * @param AdminGroups $adminGroupsHelper
31
     * @param ChatNotification $chatNotification
32
     */
33
    public function __construct(
34
        $command,
35
        string $permission,
36
        $aliases = [],
37
        AdminGroups $adminGroupsHelper,
38
        ChatNotification $chatNotification
39
    ) {
40
        parent::__construct($command, $permission, $aliases, $adminGroupsHelper);
41
42
        $this->chatNotification = $chatNotification;
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48
    public function execute($login, InputInterface $input)
49
    {
50
        if (function_exists('meminfo_dump')) {
51
            $date = date(DATE_ISO8601);
52
            meminfo_dump(fopen("eXpansion-mem-dump-$date.json", 'w'));
53
        } else {
54
            $this->chatNotification->sendMessage('meminfo is not installed!', $login);
55
        }
56
    }
57
}