Response   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A write() 0 14 2
A __construct() 0 2 1
1
<?php
2
/**
3
 * This file is part of product_management
4
 * User: Sinan TURGUT <[email protected]>
5
 * Date: 24.06.2019
6
 * php version 7.2
7
 *
8
 * @category Assessment
9
 * @package  ProductManagement
10
 * @author   Sinan TURGUT <[email protected]>
11
 * @license  See LICENSE file
12
 * @link     https://dev.sinanturgut.com.tr
13
 */
14
15
namespace App\Utility;
16
17
/**
18
 * Class Response
19
 * @package App\Utility
20
 */
21
class Response
22
{
23
    /**
24
     * Response constructor.
25
     */
26
    public function __construct()
27
    {
28
        //
29
    }
30
31
    /**
32
     * @param $succes
33
     * @param $data
34
     * @param int $httpCode
35
     */
36
    public static function write($succes, $data, $httpCode = 200)
37
    {
38
        http_response_code($httpCode);
39
40
        if ($succes) {
41
            $outPut=array('success'=>'true', 'data'=>$data);
42
43
        } else {
44
45
            $outPut=array('success'=>'false', 'error'=>$data);
46
        }
47
48
        echo json_encode($outPut, JSON_UNESCAPED_UNICODE);
49
        exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
50
    }
51
52
}