ApplicationBase   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A generateRequest() 0 4 1
A generateRequestFromGlobals() 0 4 1
handleRequest() 0 1 ?
1
<?php
2
/**
3
 * Scabbia2 LightStack Component
4
 * https://github.com/eserozvataf/scabbia2
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @link        https://github.com/eserozvataf/scabbia2-lightstack for the canonical source repository
10
 * @copyright   2010-2016 Eser Ozvataf. (http://eser.ozvataf.com/)
11
 * @license     http://www.apache.org/licenses/LICENSE-2.0 - Apache License, Version 2.0
12
 */
13
14
namespace Scabbia\LightStack;
15
16
use Scabbia\LightStack\MiddlewareInterface;
17
use Scabbia\LightStack\Request;
18
use Scabbia\LightStack\RequestInterface;
19
use Scabbia\LightStack\ResponseInterface;
20
21
/**
22
 * Default methods needed for implementation of an application
23
 *
24
 * @package     Scabbia\LightStack
25
 * @author      Eser Ozvataf <[email protected]>
26
 * @since       2.0.0
27
 */
28
abstract class ApplicationBase implements MiddlewareInterface
29
{
30
    /**
31
     * Generates a request object
32
     *
33
     * @param string      $uMethod            method
34
     * @param string      $uPathInfo          pathinfo
35
     * @param array|null  $uDetails           available keys: get, post, files, server, session, cookies, headers
36
     *
37
     * @return RequestInterface request object
38
     */
39
    public function generateRequest($uMethod, $uPathInfo, array $uDetails = null)
40
    {
41
        return new Request($uMethod, $uPathInfo, $uDetails);
42
    }
43
44
    /**
45
     * Generates a request object from globals
46
     *
47
     * @return RequestInterface request object
48
     */
49
    public function generateRequestFromGlobals()
50
    {
51
        return Request::generateFromGlobals();
52
    }
53
54
    /**
55
     * Handles a request
56
     *
57
     * @param RequestInterface $uRequest        request object
58
     * @param bool             $uIsSubRequest   whether is a sub-request or not
59
     *
60
     * @return ResponseInterface response object
61
     */
62
    abstract public function handleRequest(RequestInterface $uRequest, $uIsSubRequest);
63
}
64