Completed
Push — develop ( 0050db...7fb870 )
by Risan Bagja
01:33
created

UriParser   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 3
dl 0
loc 40
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isAbsolute() 0 4 1
A isMissingScheme() 0 4 2
A resolve() 0 4 1
A toPsrUri() 0 10 3
1
<?php
2
3
namespace Risan\OAuth1;
4
5
use GuzzleHttp\Psr7\Uri;
6
use GuzzleHttp\Psr7\UriResolver;
7
use Psr\Http\Message\UriInterface;
8
9
class UriParser implements UriParserInterface
10
{
11
    /**
12
     * {@inheritDoc}
13
     */
14
    public function isAbsolute(UriInterface $uri)
15
    {
16
        return Uri::isAbsolute($uri);
17
    }
18
19
    /**
20
     * {@inheritDoc}
21
     */
22
    public function isMissingScheme(UriInterface $uri)
23
    {
24
        return $uri->getScheme() === '' && $uri->getHost() !== '';
25
    }
26
27
    /**
28
     * {@inheritDoc}
29
     */
30
    public function resolve(UriInterface $baseUri, UriInterface $uri)
31
    {
32
        return UriResolver::resolve($baseUri, $uri);
33
    }
34
35
    /**
36
     * {@inheritDoc}
37
     */
38
    public function toPsrUri($uri)
39
    {
40
        if ($uri instanceof UriInterface) {
41
            return $uri;
42
        } elseif (is_string($uri)) {
43
            return new Uri($uri);
44
        }
45
46
        throw new InvalidArgumentException('URI must be a string or an instance of \Psr\Http\Message\UriInterface.');
47
    }
48
}
49