Completed
Push — master ( c463e3...d4f070 )
by Jan-Petter
02:17
created

DelayClient::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace vipnytt\RobotsTxtParser\Client\Directives;
3
4
use PDO;
5
use vipnytt\RobotsTxtParser\Client\Delay\DelayHandlerClient;
6
7
/**
8
 * Class DelayClient
9
 *
10
 * @package vipnytt\RobotsTxtParser\Client\Directives
11
 */
12
class DelayClient extends DelayCore implements ClientInterface
13
{
14
    /**
15
     * Value
16
     * @var float|int
17
     */
18
    private $value;
19
20
    /**
21
     * Export value
22
     * @var float|int
23
     */
24
    private $exportValue;
25
26
    /**
27
     * DelayClient constructor.
28
     *
29
     * @param string $baseUri
30
     * @param string $userAgent
31
     * @param float|int $value
32
     * @param float|int $fallbackValue
33
     */
34
    public function __construct($baseUri, $userAgent, $value, $fallbackValue = 0)
35
    {
36
        $this->exportValue = $value;
37
        $this->value = $value > 0 ? $value : $fallbackValue;
38
        parent::__construct($baseUri, $userAgent);
39
    }
40
41
    /**
42
     * Get value
43
     *
44
     * @return float|int
45
     */
46
    public function getValue()
47
    {
48
        return $this->value;
49
    }
50
51
    /**
52
     * Export
53
     *
54
     * @return float|int
55
     */
56
    public function export()
57
    {
58
        return $this->exportValue;
59
    }
60
61
    /**
62
     * Handle delay
63
     *
64
     * @param PDO $pdo
65
     * @return DelayHandlerClient
66
     */
67
    public function handle(PDO $pdo)
68
    {
69
        return new DelayHandlerClient($pdo, $this->base, $this->userAgent, $this->value);
70
    }
71
}
72