AddressDoesNotExist::withType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * PWWEB\Localisation\Exceptions.
5
 *
6
 * Address does not exist exception.
7
 *
8
 * @author    Frank Pillukeit <[email protected]>
9
 * @copyright 2020 pw-websolutions.com
10
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
11
 */
12
13
namespace PWWEB\Localisation\Exceptions;
14
15
use InvalidArgumentException;
16
17
class AddressDoesNotExist extends InvalidArgumentException
18
{
19
    /**
20
     * Creates an exception with an error message based on the address name.
21
     *
22
     * @param string $addressName the address name
23
     *
24
     * @return static
25
     */
26
    public static function create(string $addressName)
27
    {
28
        return new static("There is no address named `{$addressName}`.");
29
    }
30
31
    /**
32
     * Creates an exception with an error message based on the address ID.
33
     *
34
     * @param int $addressId the address ID which does not exist in the database
35
     *
36
     * @return static
37
     */
38
    public static function withId(int $addressId)
39
    {
40
        return new static("There is no [address] with id `{$addressId}`.");
41
    }
42
43
    /**
44
     * Creates an exception with an error message based on the address type name.
45
     *
46
     * @param string $addressType The address type name which does not exist in the database
47
     *
48
     * @return static
49
     */
50
    public static function withType(string $addressType)
51
    {
52
        return new static("There is no [address] with type `{$addressType}`.");
53
    }
54
}
55