UnsupportedLanguageException::forLanguage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
crap 1
1
<?php
2
3
/*
4
 * This file is part of the puli/repository package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Puli\Repository\Api;
13
14
use Exception;
15
use RuntimeException;
16
17
/**
18
 * Thrown when a glob language is not supported by the repository.
19
 *
20
 * @since  1.0
21
 *
22
 * @author Bernhard Schussek <[email protected]>
23
 */
24
class UnsupportedLanguageException extends RuntimeException
25
{
26
    /**
27
     * Creates an exception for an unsupported language string.
28
     *
29
     * @param string         $language The unsupported language.
30
     * @param Exception|null $cause    The exception that caused this exception.
31
     *
32
     * @return static The created exception.
33
     */
34 18
    public static function forLanguage($language, Exception $cause = null)
35
    {
36 18
        return new static(sprintf(
37 18
            'The language "%s" is not supported.',
38
            $language
39 18
        ), 0, $cause);
40
    }
41
}
42