Completed
Push — master ( 0ebeda...45d090 )
by Peter
02:31
created

RandMaxSecondsRuleBase::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * AnimeDb package.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 */
8
namespace AnimeDb\SmartSleep\Rule;
9
10
abstract class RandMaxSecondsRuleBase extends RuleBase
11
{
12
    /**
13
     * Default sleep at least seconds.
14
     *
15
     * @var int
16
     */
17
    const DEFAULT_MIN_SLEEP_SECONDS = 10;
18
19
    /**
20
     * @var int
21
     */
22
    protected $min_sleep_seconds;
23
24
    /**
25
     * @param int $min_sleep_seconds
26
     */
27 39
    public function __construct($min_sleep_seconds = self::DEFAULT_MIN_SLEEP_SECONDS)
28
    {
29 39
        $this->min_sleep_seconds = $min_sleep_seconds;
30 39
    }
31
32
    /**
33
     * @return int
34
     */
35 6
    public function getSeconds()
36
    {
37 6
        return rand($this->min_sleep_seconds, parent::getSeconds());
38
    }
39
}
40