GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 6ac76d...bfd754 )
by Cees-Jan
03:25
created

MultiGraph::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
/*
5
 * This file is part of PhuninNode.
6
 *
7
 ** (c) 2013 - 2016 Cees-Jan Kiewiet
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
/*
15
 * This file is part of PhuninNode.
16
 *
17
 ** (c) 2013 - 2016 Cees-Jan Kiewiet
18
 *
19
 * For the full copyright and license information, please view the LICENSE
20
 * file that was distributed with this source code.
21
 */
22
23
declare(strict_types=1);
24
/*
25
 * This file is part of PhuninNode.
26
 *
27
 ** (c) 2013 - 2016 Cees-Jan Kiewiet
28
 *
29
 * For the full copyright and license information, please view the LICENSE
30
 * file that was distributed with this source code.
31
 */
32
33
namespace WyriHaximus\PhuninNode\Plugins;
34
35
use React\Promise\Deferred;
36
use WyriHaximus\PhuninNode\Configuration;
37
use WyriHaximus\PhuninNode\Node;
38
use WyriHaximus\PhuninNode\PluginInterface;
39
use WyriHaximus\PhuninNode\Value;
40
41
/**
42
 * Class MultiGraph
43
 * @package WyriHaximus\PhuninNode\Plugins
44
 */
45
class MultiGraph implements PluginInterface
0 ignored issues
show
Bug introduced by
There is one abstract method getCategorySlug in this class; you could implement it, or declare this class as abstract.
Loading history...
46
{
47
    /**
48
     * @var Node
49
     */
50
    private $node;
51
52
    /**
53
     * @var array
54
     */
55
    protected $plugins = [];
56
57
    /**
58
     * @param PluginInterface[] $plugins
59
     */
60
    public function __construct(array $plugins)
61
    {
62
        $this->plugns = $plugins;
0 ignored issues
show
Bug introduced by
The property plugns does not seem to exist. Did you mean plugins?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function setNode(Node $node)
69
    {
70
        $this->node = $node;
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function getSlug()
77
    {
78
        return 'uptime';
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function getConfiguration(Deferred $deferred)
85
    {
86
        $this->configuration = new Configuration();
0 ignored issues
show
Bug introduced by
The property configuration does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
87
        $this->configuration->setPair('graph_category', 'phunin_node');
88
        $this->configuration->setPair('graph_title', 'Uptime');
89
        $this->configuration->setPair('graph_args', '--base 1000 -l 0');
90
        $this->configuration->setPair('graph_vlabel', 'uptime in days');
91
        $this->configuration->setPair('uptime.label', 'uptime');
92
        $this->configuration->setPair('uptime.draw', 'AREA');
93
94
        $deferred->resolve($this->configuration);
95
    }
96
97
    /**
98
     * {@inheritdoc}
99
     */
100
    public function getValues(Deferred $deferred)
101
    {
102
        $values = new \SplObjectStorage;
103
        $values->attach($this->getUptimeValue());
104
        $deferred->resolve($values);
105
    }
106
107
    /**
108
     * @return \WyriHaximus\PhuninNode\Value
109
     */
110
    private function getUptimeValue()
111
    {
112
        $value = new Value();
0 ignored issues
show
Bug introduced by
The call to Value::__construct() misses some required arguments starting with $key.
Loading history...
113
        $value->setKey('uptime');
0 ignored issues
show
Bug introduced by
The method setKey() does not seem to exist on object<WyriHaximus\PhuninNode\Value>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
114
        $value->setValue(round(((time() - $this->startTime) / self::DAY_IN_SECONDS), 2));
0 ignored issues
show
Bug introduced by
The property startTime does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The method setValue() does not seem to exist on object<WyriHaximus\PhuninNode\Value>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
115
        return $value;
116
    }
117
}
118