Completed
Branch erdiko2 (81b309)
by John
02:13
created

Api::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
dl 5
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 * Api Controller
4
 *
5
 * @package     erdiko/controllers
6
 * @copyright   2012-2017 Arroyo Labs, Inc. http://www.arroyolabs.com
7
 * @author      John Arroyo <[email protected]>
8
 */
9
namespace erdiko\controllers;
10
11
12 View Code Duplication
class Api extends \erdiko\Controller
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
15
  /**
16
   * Contructor
17
   */
18
    public function __construct()
19
    {
20
        $this->_webroot = ERDIKO_ROOT;
0 ignored issues
show
Bug introduced by
The property _webroot 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...
21
        $this->_response = new \erdiko\core\ApiResponse;
0 ignored issues
show
Bug introduced by
The property _response 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...
22
    }
23
24
  /**
25
   * setStatusCode
26
   *
27
   */
28
    public function setStatusCode($code = null)
29
    {
30
        if (!empty($code)) {
31
            $this->_response->setStatusCode($code);
32
        }
33
    }
34
35
    public function setErrors($errors = null)
36
    {
37
        if (!empty($errors)) {
38
            $this->_response->setErrors($errors);
39
        }
40
    }
41
}
42