Passed
Push — master ( f744eb...1e2cdf )
by F
02:42
created

AddressDoesNotExist::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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