Completed
Push — master ( e1c899...25c559 )
by Tolan
02:28
created

Response::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 3
eloc 9
nc 3
nop 3
1
<?php
2
/*
3
 * This file is part of the Patternseek ComponentView library.
4
 *
5
 * (c) 2014 Tolan Blundell <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace PatternSeek\ComponentView;
12
13
/**
14
 * Class ViewComponentResponse
15
 */
16
class Response
17
{
18
19
    /**
20
     * Currently one of "redirect" or a valid MIME type.
21
     * @var string
22
     */
23
    public $type;
24
    /**
25
     * @var string
26
     */
27
    public $content;
28
29
    /**
30
     * @param $type
31
     * @param $content
32
     * @param null $responseCode
33
     */
34
    function __construct( $type, $content, $responseCode = null )
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
35
    {
36
        $this->type = $type;
37
        $this->content = $content;
38
        
39
        // Response code defaults
40
        if( null == $responseCode ){
41
            if( $type == "redirect" ){
42
                $responseCode = 301;
43
            }else{
44
                $responseCode = 200;
45
            }
46
        }
47
        $this->responseCode = $responseCode;
0 ignored issues
show
Bug introduced by
The property responseCode does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
48
    }
49
}
50