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

Response   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 5
Bugs 1 Features 0
Metric Value
c 5
b 1
f 0
dl 0
loc 62
wmc 13
lcom 2
cbo 2
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getStatus() 0 4 1
A getContentType() 0 6 2
B getUri() 0 14 5
A getRequest() 0 4 1
A getDuration() 0 4 1
A getBody() 0 14 3
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