DuplicationDetected   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 18
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A in() 0 8 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\IdentityMap;
5
6
use InvalidArgumentException as InvalidArgument;
7
use function sprintf as withMessage;
8
9
final class DuplicationDetected extends InvalidArgument implements AlreadyThere
10
{
11
    /**
12
     * Produces an exception for when the object is already in the map.
13
     *
14
     * @param string $class The class of the proposed object.
15
     * @param string $id    The identity that is already there.
16
     * @return AlreadyThere The exception to throw.
17
     */
18
    public static function in(string $class, string $id): AlreadyThere
19
    {
20
        return new DuplicationDetected(withMessage(
21
            'The object with id `%s` of class `%s` is already in the identity map.',
22
            $id,
23
            $class
24
        ));
25
    }
26
}
27