AmazonUriFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 10
c 0
b 0
f 0
dl 0
loc 31
ccs 0
cts 8
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A assertAvailable() 0 7 2
A createUri() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Distribution\Internal;
6
7
use GuzzleHttp\Psr7\Uri;
8
use Psr\Http\Message\UriFactoryInterface;
9
use Psr\Http\Message\UriInterface;
10
11
class AmazonUriFactory implements UriFactoryInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    private const ERROR_NOT_AVAILABLE =
17
        'The "aws/aws-sdk-php" package is supplied with the Guzzle PSR-7 ' .
18
        'implementation, but it is not available. Please install the ' .
19
        '"aws/aws-sdk-php" package or use any other implementation of PSR-17 factories.'
20
    ;
21
22
    /**
23
     * AmazonUriFactory constructor.
24
     */
25
    public function __construct()
26
    {
27
        $this->assertAvailable();
28
    }
29
30
    public function createUri(string $uri = ''): UriInterface
31
    {
32
        return new Uri($uri);
33
    }
34
35
    private function assertAvailable(): void
36
    {
37
        if (\class_exists(Uri::class)) {
38
            return;
39
        }
40
41
        throw new \DomainException(self::ERROR_NOT_AVAILABLE);
42
    }
43
}
44