Completed
Push — master ( d1c429...2074bd )
by Alejandro
27:44
created

Api   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 9
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 52
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A onConfigChange() 0 3 1
A onLoad() 0 3 1
A onRemove() 0 3 1
A getError() 0 3 1
A getResponse() 0 3 1
A setError() 0 4 1
A setResponse() 0 4 1
A get() 0 8 1
1
<?php
2
3
/*
4
 * The MIT License
5
 *
6
 * Copyright 2016 Alejandro Peña Florentín ([email protected]).
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9
 * of this software and associated documentation files (the "Software"), to deal
10
 * in the Software without restriction, including without limitation the rights
11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
 * copies of the Software, and to permit persons to whom the Software is
13
 * furnished to do so, subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice shall be included in
16
 * all copies or substantial portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
 * THE SOFTWARE.
25
 */
26
27
namespace Tight\Modules\Api;
28
29
/**
30
 * Api class
31
 *
32
 * @author Alejandro Peña Florentín ([email protected])
33
 */
34
class Api extends \Tight\Modules\AbstractModule
35
{
36
37
    private $error;
38
    private $response;
39
40
    public function __construct($error = true, $response = "") {
41
        parent::__construct("ApiModule", "v1.0");
42
        $this->setError($error);
43
        $this->setResponse($response);
44
    }
45
46
    public function onConfigChange() {
47
        
48
    }
49
50
    public function onLoad() {
51
        
52
    }
53
54
    public function onRemove() {
55
        
56
    }
57
58
    public function getError() {
59
        return $this->error;
60
    }
61
62
    public function getResponse() {
63
        return $this->response;
64
    }
65
66
    public function setError($error) {
67
        $this->error = $error;
68
        return $this;
69
    }
70
71
    public function setResponse($response) {
72
        $this->response = $response;
73
        return $this;
74
    }
75
76
    public function get() {
77
        header("Content-type: application/json");
78
        $output = [
79
            "error" => $this->getError(),
80
            "response" => $this->getResponse()
81
        ];
82
        return json_encode($output);
83
    }
84
85
}
86