Completed
Push — master ( 9dca89...cdca22 )
by Frédéric G.
01:10
created

JobsRatePlugin   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 31
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A config() 15 15 1
A data() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * @file
5
 * Munin plugin for Beanstalkd "jobs rate" monitoring
6
 *
7
 * @author: Frédéric G. MARAND <[email protected]>
8
 * @copyright (c) 2014-2018 Ouest Systèmes Informatiques (OSInet)
9
 * @license Apache License 2.0 or later
10
 */
11
12
namespace OSInet\Beanstalkd\Munin;
13
14 View Code Duplication
class JobsRatePlugin extends BasePlugin
0 ignored issues
show
Duplication introduced by
This class 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...
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function config()
20
    {
21
        $ret = <<<'EOT'
22
graph_title Job Rate
23
graph_vlabel Jobs per ${graph_period}
24
graph_category Beanstalk
25
graph_args --lower-limit 0
26
graph_scale no
27
queue_jobs.label Jobs
28
queue_jobs.type DERIVE
29
queue_jobs.min 0
30
EOT;
31
32
        return $ret;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function data()
39
    {
40
        $stats = $this->server->stats();
41
        $ret = sprintf("queue_jobs.value %d\n", $stats['total-jobs']);
42
        return $ret;
43
    }
44
}
45