RateLimitException::getRetryDate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace TreeHouse\IoBundle\Scrape\Exception;
4
5
class RateLimitException extends CrawlException
6
{
7
    /**
8
     * @var \DateTime
9
     */
10
    protected $retryDate;
11
12
    /**
13
     * @param string     $url
14
     * @param string     $message
15
     * @param \DateTime  $retryDate
16
     * @param int        $code
17
     * @param \Exception $previous
18
     */
19 10
    public function __construct($url, $message = '', \DateTime $retryDate = null, $code = 0, \Exception $previous = null)
20
    {
21 10
        parent::__construct($url, $message, $code, $previous);
22
23 10
        if ($retryDate instanceof \DateTime && $retryDate < new \DateTime()) {
24
            throw new \InvalidArgumentException('$retryDate cannot be in the past');
25
        }
26
27 10
        $this->retryDate = $retryDate;
28 10
    }
29
30
    /**
31
     * @return \DateTime
32
     */
33 4
    public function getRetryDate()
34
    {
35 4
        return $this->retryDate;
36
    }
37
}
38