Test Failed
Push — develop ( 55b248...7d9761 )
by Tony
21:25
created

RRDGraph   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A fetch() 0 5 1
1
<?php
2
/**
3
 * RRDGraph.php
4
 *
5
 * -Description-
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 * @package    LibreNMS
21
 * @link       http://librenms.org
22
 * @copyright  2016 Tony Murray
23
 * @author     Tony Murray <[email protected]>
24
 */
25
26
namespace App\Data;
27
28
29
class RRDGraph extends RRD
30
{
31
    protected $supported_formats = ['png'];
32
33
    public function __construct($definitions, $start, $end, $width, $height)
34
    {
35
        $args = " graph - -s $start -e $end  --width $width --height $height ".
36
            "--alt-autoscale-max --rigid -E -c BACK#EEEEEE00 -c SHADEA#EEEEEE00 -c SHADEB#EEEEEE00 -c \
37
            FONT#000000 -c CANVAS#FFFFFF00 -c GRID#a5a5a5 -c MGRID#FF9999 -c FRAME#5e5e5e -c ARROW#5e5e5e \
38
            -R normal --font LEGEND:8:DejaVuSansMono --font AXIS:7:DejaVuSansMono --font-render-mode normal ".
39
            $definitions;
40
41
        parent::__construct($args);
42
    }
43
44
    /**
45
     * Return the output from this data source
46
     * May be base64 encoded PNG, Json Data, or CSV Data
47
     *
48
     * @param string $format png, json, or csv
49
     * @return string
50
     */
51
    public function fetch($format)
52
    {
53
        $this->checkFormatSupported($format);
54
        return base64_encode($this->run());
55
    }
56
}
57