Completed
Push — master ( 6ec45a...ca732a )
by Oscar
02:30
created

Assert::create()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 22
rs 8.6737
cc 6
eloc 11
nc 6
nop 1
1
<?php
2
3
namespace Psr7Unitesting;
4
5
use GuzzleHttp\Client;
6
use Psr\Http\Message\MessageInterface;
7
use Psr\Http\Message\RequestInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Psr\Http\Message\ResponseInterface;
10
use Psr\Http\Message\UriInterface;
11
use Psr\Http\Message\StreamInterface;
12
13
abstract class Assert
14
{
15
16
    public static function get($uri)
17
    {
18
        $client = new Client();
19
20
        return self::create($client->get($uri));
21
    }
22
23
    public static function create($object)
24
    {
25
        if ($object instanceof ServerRequestInterface) {
26
            return new ServerRequest($object);
27
        }
28
29
        if ($object instanceof RequestInterface) {
30
            return new Request($object);
31
        }
32
33
        if ($object instanceof ResponseInterface) {
34
            return new Response($object);
35
        }
36
37
        if ($object instanceof UriInterface) {
38
            return new Uri($object);
39
        }
40
41
        if ($object instanceof StreamInterface) {
42
            return new Stream($object);
43
        }
44
    }
45
}