DiskSpaceHealthIndicatorProperties::setDirectory()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 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