TargetException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 20
rs 10
ccs 8
cts 8
cp 1
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A noneExist() 0 3 1
A doesNotExist() 0 3 1
A alreadyExists() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Esi\ConsistentHash.
7
 *
8
 * (c) Eric Sizemore <[email protected]>
9
 * (c) Paul Annesley <[email protected]>
10
 *
11
 * This source file is subject to the MIT license. For the full copyright and
12
 * license information, please view the LICENSE file that was distributed with
13
 * this source code.
14
 */
15
16
namespace Esi\ConsistentHash\Exception;
17
18
/**
19
 * An exception thrown by ConsistentHash.
20
 */
21
class TargetException extends \RuntimeException
22
{
23 3
    protected function __construct(string $message)
24
    {
25 3
        parent::__construct($message);
26
    }
27
28 1
    public static function alreadyExists(string $target): self
29
    {
30 1
        return new self(\sprintf("Target '%s' already exists.", $target));
31
    }
32
33 1
    public static function doesNotExist(string $target): self
34
    {
35 1
        return new self(\sprintf("Target '%s' does not exist.", $target));
36
    }
37
38 1
    public static function noneExist(): self
39
    {
40 1
        return new self('No targets exist');
41
    }
42
}
43