RateLimitException::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 6
cp 0.8333
rs 9.9332
c 0
b 0
f 0
cc 3
nc 2
nop 5
crap 3.0416
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