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

InvalidStatusCodeException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 30
wmc 2
lcom 0
cbo 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A notNumeric() 0 7 1
A notGreaterOrEqualTo100() 0 7 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