Completed
Push — develop ( 7fa98c...fc74bf )
by Risan Bagja
01:47
created

UriParser::isMissingScheme()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Risan\OAuth1\Request;
4
5
use GuzzleHttp\Psr7\Uri;
6
use InvalidArgumentException;
7
use GuzzleHttp\Psr7\UriResolver;
8
use Psr\Http\Message\UriInterface;
9
10
class UriParser implements UriParserInterface
11
{
12
    /**
13
     * {@inheritDoc}
14
     */
15 16
    public function isAbsolute(UriInterface $uri)
16
    {
17 16
        return Uri::isAbsolute($uri);
18
    }
19
20
    /**
21
     * {@inheritDoc}
22
     */
23 8
    public function isMissingScheme(UriInterface $uri)
24
    {
25 8
        return $uri->getScheme() === '' && $uri->getHost() !== '';
26
    }
27
28
    /**
29
     * {@inheritDoc}
30
     */
31 7
    public function resolve(UriInterface $baseUri, UriInterface $uri)
32
    {
33 7
        return UriResolver::resolve($baseUri, $uri);
34
    }
35
36
    /**
37
     * {@inheritDoc}
38
     */
39 22 View Code Duplication
    public function toPsrUri($uri)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41 22
        if ($uri instanceof UriInterface) {
42 7
            return $uri;
43 22
        } elseif (is_string($uri)) {
44 21
            return new Uri($uri);
45
        }
46
47 1
        throw new InvalidArgumentException('URI must be a string or an instance of \Psr\Http\Message\UriInterface.');
48
    }
49
}
50