RequestHandlerFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 46
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getApplication() 0 3 1
A createRequestHandler() 0 9 1
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * AppserverIo\RestApi\Handlers\RequestHandler
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2018 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/restapi
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\RestApi\Handlers;
22
23
use AppserverIo\Psr\Application\ApplicationInterface;
24
25
/**
26
 * Request handler factory implementation.
27
 *
28
 * @author    Tim Wagner <[email protected]>
29
 * @copyright 2018 TechDivision GmbH <[email protected]>
30
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
31
 * @link      https://github.com/appserver-io/restapi
32
 * @link      http://www.appserver.io
33
 */
34
class RequestHandlerFactory
35
{
36
37
    /**
38
     * The application instance.
39
     *
40
     * @var \AppserverIo\Psr\Application\ApplicationInterface
41
     */
42
    protected $application;
43
44
    /**
45
     * Initializes the factory with the application instance.
46
     *
47
     * @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance
48
     */
49
    public function __construct(ApplicationInterface $application)
50
    {
51
        $this->application = $application;
52
    }
53
54
    /**
55
     * Returns the application instance.
56
     *
57
     * @return \AppserverIo\Psr\Application\ApplicationInterface The application instance
58
     */
59
    protected function getApplication()
60
    {
61
        return $this->application;
62
    }
63
64
    /**
65
     * Returns the new request handler instance.
66
     *
67
     * @param string $api The API of the request handler to be created
68
     *
69
     * @return \AppserverIo\RestApi\Handlers\RequestHandlerInterface The request handler
70
     */
71
    public function createRequestHandler($api)
72
    {
73
74
        // create a new instance of the request handler for the passed API specification
75
        $requestHandler = $this->getApplication()->search($api);
76
        $requestHandler->init();
77
78
        // return the request handler instance
79
        return $requestHandler;
80
    }
81
}
82