ClientException::assertCurlMultiStatusCodeSame()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 10
rs 10
ccs 5
cts 5
cp 1
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
/**
4
 * It's free open-source software released under the MIT License.
5
 *
6
 * @author Anatoly Nekhay <[email protected]>
7
 * @copyright Copyright (c) 2018, Anatoly Nekhay
8
 * @license https://github.com/sunrise-php/http-client-curl/blob/master/LICENSE
9
 * @link https://github.com/sunrise-php/http-client-curl
10
 */
11
12
declare(strict_types=1);
13
14
namespace Sunrise\Http\Client\Curl\Exception;
15
16
use Psr\Http\Client\ClientExceptionInterface;
17
use RuntimeException;
18
19
use function curl_multi_strerror;
20
21
class ClientException extends RuntimeException implements ClientExceptionInterface
22
{
23
    /**
24
     * @throws self
25
     */
26 3
    final public static function assertCurlMultiStatusCodeSame(int $expectedStatusCode, int $actualStatusCode): void
27
    {
28 3
        if ($expectedStatusCode === $actualStatusCode) {
29 3
            return;
30
        }
31
32
        /** @var string $message */
33 1
        $message = curl_multi_strerror($actualStatusCode);
34
35 1
        throw new self($message, $actualStatusCode);
36
    }
37
}
38