startDateNotBeforeEndDate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Arbor\Moment\Exception;
6
7
use Arbor\Moment\DateTime;
8
use Arbor\Moment\Time;
9
10
/**
11
 * Class InvalidArgumentException
12
 *
13
 * @package Arbor\Moment\Exception
14
 * @author Igor Vuckovic <[email protected]>
15
 */
16
class InvalidArgumentException extends \InvalidArgumentException
17
{
18
    /**
19
     * @param DateTime $startDate
20
     * @param DateTime $endDate
21
     * @return InvalidArgumentException
22
     */
23 3
    public static function startDateNotBeforeEndDate(DateTime $startDate, DateTime $endDate) : InvalidArgumentException
24
    {
25 3
        return new self(sprintf(
26 3
            'Start date "%s" in date range must be before the end date "%s"',
27 3
            $startDate->getLong(), $endDate->getLong()
28
        ));
29
    }
30
31
    /**
32
     * @param string|int $time
33
     * @return InvalidArgumentException
34
     */
35 4
    public static function invalidTimeFormat($time) : InvalidArgumentException
36
    {
37 4
        return new self(sprintf(
38 4
            'Invalid time format "%s" provided as argument for "%s"', $time, Time::class
39
        ));
40
    }
41
42
    /**
43
     * @return InvalidArgumentException
44
     */
45 4
    public static function dateRangeWithoutBoundaries() : InvalidArgumentException
46
    {
47 4
        return new self(sprintf(
48 4
            'Date Range must have either %s or %s defined',
49 4
            '$startDate', '$endDate'
50
        ));
51
    }
52
}
53