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

AddressDoesNotExist   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A withId() 0 3 1
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