RateLimitException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 33
ccs 7
cts 8
cp 0.875
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A getRetryDate() 0 4 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