DetectsDeadlocks   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A causedByDeadlock() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\Aranguent\Concerns;
6
7
use Exception;
8
9
trait DetectsDeadlocks
10
{
11
    /**
12
     * Determine if the given exception was caused by a deadlock.
13
     * @see https://www.arangodb.com/docs/stable/appendix-error-codes.html
14
     *
15
     * @return bool
16
     */
17
    protected function causedByDeadlock(Exception $e)
18
    {
19
        $code = $e->getCode();
20
21
        return in_array($code, [
22
            18,     // ERROR_LOCK_TIMEOUT
23
            28,     // ERROR_LOCKED
24
            29,     // ERROR_DEADLOCK
25
            1200,   // ERROR_ARANGO_CONFLICT (write-write conflict)
26
            1302,   // ERROR_ARANGO_TRY_AGAIN
27
            1303,   // ERROR_ARANGO_BUSY
28
            1304,   // ERROR_ARANGO_MERGE_IN_PROGRESS
29
            1521,   // ERROR_QUERY_COLLECTION_LOCK_FAILED
30
            7009,   // ERROR_LOCAL_LOCK_FAILED
31
            7010,   // ERROR_LOCAL_LOCK_RETRY
32
        ]);
33
    }
34
}
35