Xhgui_Controller_Import::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
use Slim\Slim;
4
5
class Xhgui_Controller_Import extends Xhgui_Controller
6
{
7
    /**
8
     * @var Xhgui_Saver_Interface
9
     */
10
    private $saver;
11
12
    public function __construct(Slim $app, Xhgui_Saver_Interface $saver)
13
    {
14
        parent::__construct($app);
15
        $this->saver = $saver;
16
    }
17
18
    public function import()
19
    {
20
        $request = $this->app->request();
21
        $response = $this->app->response();
22
23
        $data = json_decode($request->getBody(), true);
24
        $this->saver->save($data);
25
26
        $response['Content-Type'] = 'application/json';
27
        $response->body(json_encode(['ok' => true]));
0 ignored issues
show
Bug introduced by
The method body cannot be called on $response (of type array<string,string,{"Content-Type":"string"}>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
28
    }
29
}
30