Xhgui_Controller_Import   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A import() 0 11 1
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