UriFactory::createUri()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 6
nc 2
nop 1
crap 3
1
<?php
2
3
namespace CodeJet\Http\Factory;
4
5
use CodeJet\Http\Uri;
6
use Interop\Http\Factory\UriFactoryInterface;
7
use InvalidArgumentException;
8
9
class UriFactory implements UriFactoryInterface
10
{
11
    /**
12
     * @inheritdoc
13
     */
14 12
    public function createUri($uri = '')
15
    {
16 12
        if (!is_string($uri)) {
17 3
            throw new InvalidArgumentException(sprintf(
18 3
                'URI passed to constructor must be a string; received "%s"',
19 3
                (is_object($uri) ? get_class($uri) : gettype($uri))
20
            ));
21
        }
22
23 9
        return new Uri($uri);
24
    }
25
}
26