JarvisResponse::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4286
cc 1
eloc 4
nc 1
nop 3
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