Completed
Push — master ( c564cb...34935e )
by Mark
02:40
created

src/Xhgui/Controller/Import.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
use Slim\Slim;
4
5
class Xhgui_Controller_Import extends Xhgui_Controller
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    /**
8
     * @var Xhgui_Saver_Mongo
9
     */
10
    private $saver;
11
12
    public function __construct(Slim $app, Xhgui_Saver_Mongo $saver)
13
    {
14
        $this->app = $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
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