LanguageDoesNotExist::create()   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
namespace PWWEB\Localisation\Exceptions;
4
5
/**
6
 * PWWEB\Localisation\Exceptions.
7
 *
8
 * Language does not exist exception.
9
 *
10
 * @author    Frank Pillukeit <[email protected]>
11
 * @copyright 2020 pw-websolutions.com
12
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
13
 */
14
15
use InvalidArgumentException;
16
17
class LanguageDoesNotExist extends InvalidArgumentException
18
{
19
    /**
20
     * Creates an exception with an error message based on the language name or locale.
21
     *
22
     * @param string $languageName the language name or locale
23
     *
24
     * @return static
25
     */
26
    public static function create(string $languageName)
27
    {
28
        return new static("There is no language named `{$languageName}`.");
29
    }
30
31
    /**
32
     * Creates an exception with an error message based on the language ID.
33
     *
34
     * @param int $languageId the language ID which does not exist in the database
35
     *
36
     * @return static
37
     */
38
    public static function withId(int $languageId)
39
    {
40
        return new static("There is no [language] with id `{$languageId}`.");
41
    }
42
}
43