RequestFactory::createRequest()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 6
nc 2
nop 2
crap 2
1
<?php
2
3
namespace CodeJet\Http\Factory;
4
5
use CodeJet\Http\Request;
6
use CodeJet\Http\Uri;
7
use Interop\Http\Factory\RequestFactoryInterface;
8
use Psr\Http\Message\UriInterface;
9
10
class RequestFactory implements RequestFactoryInterface
11
{
12
    /**
13
     * @inheritdoc
14
     */
15 21
    public function createRequest($method, $uri)
16
    {
17 21
        if (!$uri instanceof UriInterface) {
18 18
            $uri = new Uri($uri);
19
        }
20
21 21
        return (new Request())
22 21
            ->withMethod($method)
23 21
            ->withUri($uri);
24
    }
25
}
26