Completed
Push — master ( e5b278...9ec350 )
by Nils
04:37
created

Response::getUri()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 14
rs 8.8571
cc 5
eloc 7
nc 5
nop 0
1
<?php
2
3
namespace whm\Smoke\Http;
4
5
use whm\Html\Uri;
6
7
class Response extends \Ivory\HttpAdapter\Message\Response
8
{
9
    private $contents;
10
11
    public function getStatus()
12
    {
13
        return $this->getStatusCode();
14
    }
15
16
    public function getContentType()
17
    {
18
        $exploded = explode(';', $this->hasHeader('Content-Type') ? $this->getHeader('Content-Type')[0] : null);
19
20
        return array_shift($exploded);
21
    }
22
23
    /**
24
     * @return Uri
25
     */
26
    public function getUri()
27
    {
28
        if ($this->getParameters('request') != null) {
0 ignored issues
show
Unused Code introduced by
The call to Response::getParameters() has too many arguments starting with 'request'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
29
            if (array_key_exists("request", $this->getParameters('request'))) {
0 ignored issues
show
Unused Code introduced by
The call to Response::getParameters() has too many arguments starting with 'request'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
30
                if ($this->getParameters('request')["request"]->getParameters() != null) {
0 ignored issues
show
Unused Code introduced by
The call to Response::getParameters() has too many arguments starting with 'request'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
31
                    if (array_key_exists("parent_request", $this->getParameters('request')["request"]->getParameters())) {
0 ignored issues
show
Unused Code introduced by
The call to Response::getParameters() has too many arguments starting with 'request'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
32
                        return $this->getParameters('request')["request"]->getParameters()["parent_request"]->getUri();
0 ignored issues
show
Unused Code introduced by
The call to Response::getParameters() has too many arguments starting with 'request'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
33
                    }
34
                }
35
            }
36
        }
37
38
        return $this->getParameter('request')->getUri();
39
    }
40
41
    /**
42
     * @return Request
43
     */
44
    public function getRequest()
45
    {
46
        return $this->getParameter('request');
47
    }
48
49
    public function getDuration()
50
    {
51
        return $this->getParameter('duration');
52
    }
53
54
    public function getBody()
55
    {
56
        if (!$this->contents) {
57
            $contents = parent::getBody()->getContents();
58
59
            if (false !== $content = @gzdecode($contents)) {
60
                $contents = $content;
61
            }
62
63
            $this->contents = $contents;
64
        }
65
66
        return $this->contents;
67
    }
68
}
69