ConcurrentUpdateOccurred   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A ofEntity() 0 6 1
A renderIdentifier() 0 9 2
1
<?php
2
3
namespace TalisOrm;
4
5
use RuntimeException;
6
7
final class ConcurrentUpdateOccurred extends RuntimeException
8
{
9 4
    public static function ofEntity(Entity $entity): ConcurrentUpdateOccurred
10
    {
11 4
        return new self(sprintf(
12 4
            'A concurrent update occurred of an entity of type "%s" with identifier: %s',
13 4
            get_class($entity),
14 4
            self::renderIdentifier($entity->identifier())
15
        ));
16
    }
17
18
    /**
19
     * @param array<string, mixed> $identifier
20
     */
21 4
    private static function renderIdentifier(array $identifier): string
22
    {
23 4
        $parts = [];
24
25 4
        foreach ($identifier as $columnName => $value) {
26 4
            $parts[] = $columnName . ' = ' . var_export($value, true);
27
        }
28
29 4
        return implode(', ', $parts);
30
    }
31
}
32