PHPStorageFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 13
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 3 1
A create() 0 6 1
1
<?php
2
3
namespace BenTools\MercurePHP\Storage\PHP;
4
5
use BenTools\MercurePHP\Storage\StorageFactoryInterface;
6
use React\Promise\PromiseInterface;
7
use RingCentral\Psr7\Uri;
8
9
use function BenTools\QueryString\query_string;
10
use function React\Promise\resolve;
11
12
final class PHPStorageFactory implements StorageFactoryInterface
13
{
14
    public function supports(string $dsn): bool
15
    {
16 3
        return 0 === \strpos($dsn, 'php://');
17
    }
18 3
19
    public function create(string $dsn): PromiseInterface
20
    {
21 1
        $qs = query_string(new Uri($dsn));
22
        $size = $qs->getParam('size') ?? 0;
23 1
24 1
        return resolve(new PHPStorage((int) $size));
25
    }
26
}
27