Completed
Branch master (6a6544)
by Pierre-Henry
33:43
created

system/modules/api/controllers/MainController.php (1 issue)

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
 * @author         Pierre-Henry Soria <[email protected]>
4
 * @copyright      (c) 2015-2017, Pierre-Henry Soria. All Rights Reserved.
5
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
6
 * @package        PH7 / App / System / Module / Api / Controller
7
 * @link           http://ph7cms.com
8
 * @link           http://github.com/pH7Software/pH7CMS-HTTP-REST-Push-Data
9
 */
10
namespace PH7;
11
12
use PH7\Framework\Http\Rest\Rest;
13
14
class MainController extends Controller
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type PH7\MainController has been defined more than once; this definition is ignored, only the first definition in _install/controllers/MainController.php (L14-23) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
15
{
16
17
    use Framework\Api\Api; // Import the Api Trait
18
19
    protected $oRest;
20
21
    public function __construct()
22
    {
23
        parent::__construct();
24
25
        $this->oRest = new Rest;
26
    }
27
28
    /**
29
     * Test if the API works well.
30
     */
31
    public function test()
32
    {
33
        if ($this->oRest->getRequestMethod() != 'POST')
34
            $this->oRest->response('', 406);
35
        else
36
            $this->oRest->response($this->set(array('return' => 'It Works!')));
37
    }
38
39
}