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

DumpMemory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 5
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
}