DiskSpaceHealthIndicatorProperties   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 2 Features 1
Metric Value
wmc 4
c 4
b 2
f 1
lcom 2
cbo 0
dl 0
loc 61
ccs 12
cts 12
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDirectory() 0 4 1
A setDirectory() 0 6 1
A getThreshold() 0 4 1
A setThreshold() 0 5 1
1
<?php
2
3
namespace Actuator\Health\Indicator;
4
5
/**
6
 * External configuration properties for DiskSpaceHealthIndicator.
7
 */
8
class DiskSpaceHealthIndicatorProperties
9
{
10
    /**
11
     * One MB in bytes.
12
     */
13
    const MEGABYTES = 1048576;
14
15
    /**
16
     * Default threshold - 10MB.
17
     */
18
    const DEFAULT_THRESHOLD = 10485760;
19
20
    /**
21
     * Path used to compute the available disk space.
22
     *
23
     * @var string
24
     */
25
    private $directory = '.';
26
27
    /**
28
     * Minimum disk space that should be available, in bytes.
29
     *
30
     * @var int
31
     */
32
    private $threshold = self::DEFAULT_THRESHOLD;
33
34
    /**
35
     * @return string
36
     */
37
    public function getDirectory()
38
    {
39 9
        return $this->directory;
40
    }
41 9
42
    /**
43
     * @param string $directory
44
     */
45
    public function setDirectory($directory)
46
    {
47 9
        assert(is_dir($directory), 'Path '.$directory.' is not a directory');
48
        assert(is_readable($directory), 'Path '.$directory.' cannot be read');
49 9
        $this->directory = $directory;
50 9
    }
51 9
52 9
    /**
53
     * @return int
54
     */
55
    public function getThreshold()
56
    {
57 9
        return $this->threshold;
58
    }
59 9
60
    /**
61
     * @param int $threshold
62
     */
63
    public function setThreshold($threshold)
64
    {
65 9
        assert(intval($threshold) > 0, 'Threshold must be greater than 0');
66
        $this->threshold = $threshold;
67 9
    }
68
}
69