RemoteProcessesGauge::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 9.4285
cc 1
eloc 7
nc 1
nop 5
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Petrica
5
 * Date: 5/29/2016
6
 * Time: 16:24
7
 */
8
namespace Petrica\StatsdSystem\Gauge;
9
10
use Petrica\StatsdSystem\Model\RemoteTopCommand;
11
12
class RemoteProcessesGauge extends ProcessesGauge
13
{
14
    /**
15
     * SSH Connection string
16
     *
17
     * @var string
18
     */
19
    protected $sshString;
20
21
    /**
22
     * Path to private key
23
     *
24
     * @var string
25
     */
26
    protected $sshIdentityFile;
27
28
    /**
29
     * Ssh port
30
     *
31
     * @var string
32
     */
33
    protected $sshPort;
34
35
36 1
    public function __construct($sshString, $sshPort = null, $sshIdentityFile = null, $cpuAbove = 5.0, $memoryAbove = 1.0)
37
    {
38 1
        parent::__construct($cpuAbove, $memoryAbove);
39
40 1
        $this->sshString = $sshString;
41 1
        $this->sshIdentityFile = $sshIdentityFile;
42 1
        $this->sshPort = $sshPort;
43
44 1
        $this->command = new RemoteTopCommand($this->sshString, $this->sshPort, $this->sshIdentityFile);
45
46
47 1
        $this->namespace = preg_replace('/[^-+_.A-Za-z0-9]*/i', '', 'statsd.' . $this->sshString . '.' . $this->sshPort);
48
    }
49
}