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 ( b3985c...948e2f )
by Cees-Jan
09:54
created

MemoryUsage::getCapabilities()   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
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
declare(strict_types=1);
3
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
namespace WyriHaximus\PhuninNode\Plugins;
14
15
use React\Promise\PromiseInterface;
16
use WyriHaximus\PhuninNode\Configuration;
17
use WyriHaximus\PhuninNode\Metric;
18
use WyriHaximus\PhuninNode\Node;
19
use WyriHaximus\PhuninNode\PluginInterface;
20
use function React\Promise\resolve;
21
use function WyriHaximus\PhuninNode\metricPromisesToObjectStorage;
22
23
/**
24
 * Class MemoryUsage
25
 * @package WyriHaximus\PhuninNode\Plugins
26
 */
27
class MemoryUsage implements PluginInterface
28
{
29
    /**
30
     * @var Node
31
     */
32
    private $node;
33
34
    /**
35
     * Cached configuration state
36
     *
37
     * @var Configuration
38
     */
39
    private $configuration;
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 7
    public function setNode(Node $node)
45
    {
46 7
        $this->node = $node;
47 7
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52 1
    public function getSlug(): string
53
    {
54 1
        return 'memory_usage';
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60 1
    public function getCategorySlug(): string
61
    {
62 1
        return 'phunin_node';
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68 2 View Code Duplication
    public function getConfiguration(): PromiseInterface
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...
69
    {
70 2
        if ($this->configuration instanceof Configuration) {
71 1
            return resolve($this->configuration);
72
        }
73
74 2
        $this->configuration = new Configuration();
75 2
        $this->configuration->setPair('graph_category', 'phunin_node');
76 2
        $this->configuration->setPair('graph_title', 'Memory Usage');
77 2
        $this->configuration->setPair('memory_usage.label', 'Current Memory Usage');
78 2
        $this->configuration->setPair('memory_peak_usage.label', 'Peak Memory Usage');
79 2
        $this->configuration->setPair('internal_memory_usage.label', 'Internal Current Memory Usage');
80 2
        $this->configuration->setPair('internal_memory_peak_usage.label', 'Internal Peak Memory Usage');
81
82 2
        return resolve($this->configuration);
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88 2
    public function getValues(): PromiseInterface
89
    {
90 2
        return metricPromisesToObjectStorage([
91 2
            new Metric('memory_usage', memory_get_usage(true)),
92 2
            new Metric('memory_peak_usage', memory_get_peak_usage(true)),
93 2
            new Metric('internal_memory_usage', memory_get_usage()),
94 2
            new Metric('internal_memory_peak_usage', memory_get_peak_usage()),
95
        ]);
96
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101
    public function getCapabilities(): array
102
    {
103
        return [];
104
    }
105
}
106