JarvisResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A send() 0 8 1
1
<?php
2
3
namespace JarvisPHP\Core;
4
5
/**
6
 * JarvisResponse
7
 * the json response of JarvisPHP
8
 * 
9
 * @author Stefano Bianchini
10
 */
11
class JarvisResponse {
12
    private $success = false;
13
    private $answer = '';
14
    private $choosen_plugin = 'none';
15
    
16
    public function __construct($answer, $choosen_plugin='none', $success=false) {
17
        $this->answer = $answer;
18
        $this->choosen_plugin = $choosen_plugin;
19
        $this->success = $success;
20
    }
21
    
22
    public function send() {
23
        JarvisPHP::$slim->response->headers->set('Content-Type', 'application/json');
24
        $response = new \stdClass();
25
        $response->answer = $this->answer;
26
        $response->success = $this->success;
27
        $response->choosen_plugin = $this->choosen_plugin;
28
        JarvisPHP::$slim->response->setBody(json_encode($response));
29
    }
30
}
31