Passed
Pull Request — master (#44)
by Anatoly
34:56
created

ClientException::assertCurlMultiStatusCodeSame()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 10
ccs 3
cts 5
cp 0.6
rs 10
cc 2
nc 2
nop 2
crap 2.2559
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 1
    final public static function assertCurlMultiStatusCodeSame(int $expectedStatusCode, int $actualStatusCode): void
27
    {
28 1
        if ($expectedStatusCode === $actualStatusCode) {
29 1
            return;
30
        }
31
32
        /** @var string $message */
33
        $message = curl_multi_strerror($actualStatusCode);
34
35
        throw new self($message, $actualStatusCode);
36
    }
37
}
38