Test Failed
Push — master ( afff71...acc55b )
by Alexey
04:46
created

Result   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 81.25%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 35
ccs 13
cts 16
cp 0.8125
rs 10
wmc 8
lcom 1
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
C send() 0 25 8
1
<?php
2
3
/**
4
 * Result
5
 *
6
 * @author Alexey Krupskiy <[email protected]>
7
 * @link http://inji.ru/
8
 * @copyright 2015 Alexey Krupskiy
9
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
10
 */
11
12
namespace Server;
13
14
class Result extends \Object {
15
16
    public $content = null;
17
    public $success = true;
18
    public $successMsg = '';
19
    public $commands = [];
20
    public $scripts = [];
21
    public $asObject = false;
22 1
23 1
    public function send($applyCallback = false) {
24 1
        $return = [];
25 1
        $return['success'] = $this->success;
26 1
        if ($this->success) {
27 1
            $return['content'] = $this->content;
28 1
            $return['successMsg'] = $this->successMsg;
29
        } else {
30
            $return['error'] = $this->content;
31 1
        }
32
        if (!headers_sent()) {
33
            header('Content-type: application/json');
34 1
        }
35 1
        $return['commands'] = $this->commands;
36 1
        $return['scripts'] = \App::$cur->view->getScripts();
37 1
        if ($applyCallback && !empty($_GET['callback'])) {
38 1
            echo $_GET['callback'] . '(';
39
        }
40
        echo json_encode($return, $this->asObject ? JSON_FORCE_OBJECT : null);
41
        if ($applyCallback && !empty($_GET['callback'])) {
42
            echo ')';
43
        }
44
45
        \Inji::$inst->stop();
46
        return true;
47
    }
48
}