Home   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0
ccs 0
cts 10
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A show() 0 9 1
1
<?php
2
3
/**
4
 * Controller to test
5
 *
6
 * @category  	src
7
 * @package   	src\Demo\Controller
8
 * @author    	Judicaël Paquet <[email protected]>
9
 * @copyright 	Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93)
10
 * @license   	https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël
11
 * @version   	Release: 1.0.0
12
 * @filesource	https://github.com/las93/venus2
13
 * @link      	https://github.com/las93
14
 * @since     	1.0
15
 */
16
17
namespace Venus\src\Demo\Controller;
18
19
use \Venus\src\Demo\common\Controller as Controller;
20
21
/**
22
 * Controller to test
23
 *
24
 * @category  	src
25
 * @package   	src\Demo\Controller
26
 * @author    	Judicaël Paquet <[email protected]>
27
 * @copyright 	Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93)
28
 * @license   	https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël
29
 * @version   	Release: 1.0.0
30
 * @filesource	https://github.com/las93/venus2
31
 * @link      	https://github.com/las93
32
 * @since     	1.0
33
 */
34
35
class Home extends Controller {
36
37
	/**
38
	 * Constructor
39
	 *
40
	 * @access public
41
	 * @return object
42
	 */
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
43
44
	public function __construct() {
45
46
		parent::__construct();
47
	}
48
49
	/**
50
	 * the main page
51
	 *
52
	 * @access public
53
	 * @return void
54
	 */
55
56
	public function show() {
57
58
		$response = new \Venus\lib\Response();
59
60
		$response->setContent('<html><body><h1>Hello world!</h1></body></html>');
61
		$response->setStatusCode(\Venus\lib\Response::HTTP_OK);
62
		$response->headers->set('Content-Type', 'text/html');
0 ignored issues
show
Bug introduced by
The method set does only exist in Venus\lib\Request\Headers, but not in Closure.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
63
		$response->send();
64
	}
65
}
66