Completed
Pull Request — master (#8)
by Romain
04:20
created

AbstractException::mustBeBool()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace ker0x\Push\Adapter\Fcm\Message\Exception;
3
4
use Exception;
5
6
abstract class AbstractException extends Exception
7
{
8
9
    /**
10
     * Display if the value must be a string.
11
     *
12
     * @param string $key The key that is wrong.
13
     * @return static
14
     */
15
    public static function mustBeString($key)
16
    {
17
        return new static(sprintf("%s must be a string.", $key));
18
    }
19
20
    /**
21
     * Display if the value must be a bool.
22
     *
23
     * @param string $key The key that is wrong.
24
     * @return static
25
     */
26
    public static function mustBeBool($key)
27
    {
28
        return new static(sprintf("%s must be a boolean.", $key));
29
    }
30
31
    /**
32
     * Display if the value must be an int.
33
     *
34
     * @param string $key The key that is wrong.
35
     * @return static
36
     */
37
    public static function mustBeInt($key)
38
    {
39
        return new static(sprintf("%s must be an integer.", $key));
40
    }
41
42
    /**
43
     * Display if an array is empty.
44
     *
45
     * @return static
46
     */
47
    public static function arrayEmpty()
48
    {
49
        return new static("Array can not be empty.");
50
    }
51
}
52