Completed
Push — master ( e9dd35...1495e9 )
by Barney
9s
created

notGreaterOrEqualTo100()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
/**
3
 * Exception thrown when the Status Code is invalid.
4
 *
5
 * PHP version 5.3
6
 *
7
 * @category Exception
8
 *
9
 * @package Teapot
10
 *
11
 * @author    Barney Hanlon <[email protected]>
12
 * @copyright 2013-2016 B Hanlon. All rights reserved.
13
 * @license   MIT http://opensource.org/licenses/MIT
14
 * @link      https://shrikeh.github.com/teapot
15
 */
16
namespace Teapot\StatusCodeException;
17
18
use InvalidArgumentException;
19
20
/**
21
 * Exception thrown when the Status Code is invalid.
22
 *
23
 * PHP version 5.3
24
 *
25
 * @category Exception
26
 *
27
 * @package Teapot
28
 *
29
 * @author    Barney Hanlon <[email protected]>
30
 * @copyright 2013-2016 B Hanlon. All rights reserved.
31
 * @license   MIT http://opensource.org/licenses/MIT
32
 * @link      https://shrikeh.github.com/teapot
33
 */
34
class InvalidStatusCodeException extends InvalidArgumentException
35
{
36
    /**
37
     * Named constructor for non-numeric status codes.
38
     *
39
     * @param mixed $code the non-numeric code
40
     * @return InvalidStatusCodeException
41
     */
42
    public static function notNumeric($code)
43
    {
44
        return new self(sprintf(
45
            'Status code must be numeric, but received %d',
46
            $code
47
        ));
48
    }
49
50
    /**
51
     * Named constructor for numeric status codes below 100.
52
     *
53
     * @param mixed $code the status code
54
     * @return InvalidStatusCodeException
55
     */
56
    public static function notGreaterOrEqualTo100($code)
57
    {
58
        return new self(sprintf(
59
            'Status code must be 100 or greater but code was %d',
60
            $code
61
        ));
62
    }
63
}
64