PHPStorageFactory::supports()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
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