ResponseUtility   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 32
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A redirect() 0 4 1
A redirectSelf() 0 5 1
1
<?php
2
3
namespace Anax\Response;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
8
/**
9
 * Handling a response and includes utilitie methods.
10
 */
11
class ResponseUtility extends Response implements
12
    ContainerInjectableInterface
13
{
14
    use ContainerInjectableTrait;
15
16
17
18
    /**
19
     * Redirect to another page and creating an url from the argument.
20
     *
21
     * @param string $url to redirect to
22
     *
23
     * @return self
24
     */
25 1
    public function redirect(string $url) : object
26
    {
27 1
        return parent::redirect($this->di->get("url")->create($url));
28
    }
29
30
31
32
    /**
33
     * Redirect to current page.
34
     *
35
     * @return self
36
     */
37 1
    public function redirectSelf() : object
38
    {
39 1
        $url = $this->di->get("request")->getCurrentUrl();
40 1
        return parent::redirect($this->di->get("url")->create($url));
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (redirect() instead of redirectSelf()). Are you sure this is correct? If so, you might want to change this to $this->redirect().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
41
    }
42
}
43