Passed
Push — master ( 831b13...b16921 )
by Rogier
02:01 queued 12s
created

LocalChallengeTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 6
c 1
b 0
f 1
dl 0
loc 13
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A http() 0 11 3
1
<?php
2
3
namespace Rogierw\RwAcme\Support;
4
5
use Rogierw\RwAcme\Exceptions\DomainValidationException;
6
use Rogierw\RwAcme\Http\Client;
7
8
class LocalChallengeTest
9
{
10
    public static function http(string $domain, string $token, string $keyAuthorization): void
11
    {
12
        $httpClient = new Client($domain);
13
14
        $response = $httpClient->get($domain . '/.well-known/acme-challenge/' . $token);
15
16
        if ($response->getHttpResponseCode() === 200 && $response->getBody() === $keyAuthorization) {
17
            return;
18
        }
19
20
        throw DomainValidationException::localHttpChallengeTestFailed($response->getHttpResponseCode());
21
    }
22
}