ReferencePoint   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 40%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 52
ccs 6
cts 15
cp 0.4
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getName() 0 4 1
A getBytes() 0 4 1
A getKiloBytes() 0 4 1
A addBytes() 0 8 2
1
<?php
2
3
namespace ArjanSchouten\HtmlMinifier\Statistics;
4
5
use InvalidArgumentException;
6
7
class ReferencePoint
8
{
9
    private $name;
10
11
    private $bytes;
12
13
    /**
14
     * @param string $name
15
     * @param int $bytes
16
     */
17 5
    public function __construct($name, $bytes)
18
    {
19 5
        $this->name = $name;
20 5
        $this->bytes = $bytes;
21 5
    }
22
23
    /**
24
     * @return string
25
     */
26
    public function getName()
27
    {
28
        return $this->name;
29
    }
30
31
    /**
32
     * @return int
33
     */
34 1
    public function getBytes()
35
    {
36 1
        return $this->bytes;
37
    }
38
39
    /**
40
     * @return float
0 ignored issues
show
Documentation introduced by
Should the return type not be integer?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
41
     */
42
    public function getKiloBytes()
43
    {
44
        return $this->bytes / 1000;
45
    }
46
47
    /**
48
     * @param int $bytes
49
     */
50
    public function addBytes($bytes)
51
    {
52
        if ($bytes < 0) {
53
            throw new InvalidArgumentException('The passed bytes amount is below zero: '.$bytes);
54
        }
55
56
        $this->bytes += $bytes;
57
    }
58
}
59