Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
RetryDecider
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
1 / 1
 shouldRetry
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2
3namespace Javidnikoo\LaravelAtlassian\Atlassian\Http;
4
5use Illuminate\Http\Client\RequestException;
6use Throwable;
7
8final class RetryDecider
9{
10    public static function shouldRetry(Throwable $e): bool
11    {
12        if (! $e instanceof RequestException) {
13            return true;
14        }
15
16        $status = $e->response?->status();
17
18        if ($status === null) {
19            return true;
20        }
21
22        if ($status >= 500) {
23            return true;
24        }
25
26        return false;
27    }
28}