Completed
Pull Request — develop (#53)
by Patrick
03:17
created

WebSite   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 3
lcom 0
cbo 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A registerPage() 0 4 1
A registerAPI() 0 6 1
1
<?php
2
namespace Http;
3
4
use \Psr\Http\Message\ServerRequestInterface as Request;
5
use \Psr\Http\Message\ResponseInterface as Response;
6
7
require 'vendor/autoload.php';
8
9
class WebSite extends \Slim\App
10
{
11
    public function __construct()
12
    {
13
        $settings = array("settings"=>["determineRouteBeforeAppMiddleware"=>true]);
14
        parent::__construct($settings);
15
        $c = $this->getContainer();
16
        $c['errorHandler'] = function($c) { return new WebErrorHandler();};
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
        $this->add(new AuthMiddleware());
18
        $this->add(new ODataMiddleware());
19
    }
20
21
    public function registerPage($uri, $page)
22
    {
23
        $this->get($uri, array($page, 'handleRequest'));
24
    }
25
26
    public function registerAPI($uri, $api)
27
    {
28
        $group = $this->group($uri, function() use($api){$api->setup($this);});
29
        $group->add(new \Http\Rest\SerializationMiddleware());
30
        $group->add(new \Http\Rest\CORSMiddleware($this->getContainer()));
31
    }
32
}
33