ErrorDetectionStrategy   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 1
b 0
f 0
dl 0
loc 15
ccs 8
cts 9
cp 0.8889
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A isTransient() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace YucaDoo\BgyNeighborhoodsDiagnostic;
6
7
use Bgy\TransientFaultHandling\ErrorDetectionStrategy as BgyErrorDetectionStrategy;
8
use Neighborhoods\ThrowableDiagnosticComponent\DiagnosedInterface;
9
use Neighborhoods\ThrowableDiagnosticComponent\ThrowableDiagnostic;
10
use Throwable;
11
12
class ErrorDetectionStrategy implements BgyErrorDetectionStrategy
13
{
14 2
    use ThrowableDiagnostic\Builder\Factory\AwareTrait;
15
16 6
    public function isTransient(Throwable $throwable): bool
17
    {
18
        try {
19 6
            $this->getThrowableDiagnosticBuilderFactory()
20 6
                ->create()
21 6
                ->build()
22 6
                ->diagnose($throwable);
23 6
        } catch (DiagnosedInterface $diagnosed) {
24 6
            return $diagnosed->isTransient();
25
        }
26
        return false;
27
    }
28
}
29