ErrorDetectionStrategy::isTransient()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2.0078

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 11
ccs 7
cts 8
cp 0.875
rs 10
cc 2
nc 2
nop 1
crap 2.0078
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