-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathApplication.php
More file actions
43 lines (38 loc) · 938 Bytes
/
Application.php
File metadata and controls
43 lines (38 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace DesignPatterns\Creational\FactoryMethod;
/**
* Application abstract base class. Defines a framework for concrete applications.
*
* It corresponds to `Creator` in the Factory Method pattern.
*
* @author Vlad Riabchenko <contact@vria.eu>
*/
abstract class Application
{
/**
* This is the factory method.
*
* @return RouterInterface
*/
public abstract function createRouter();
/**
* This is another factory method.
*
* @param $requestURL
*
* @return RequestInterface
*/
public abstract function createRequest($requestURL);
/**
* @param $requestURL
*
* @return string
*/
public function handle($requestURL)
{
$request = $this->createRequest($requestURL);
$router = $this->createRouter();
$handler = $router->resolveHandler($request);
return call_user_func($handler, $request);
}
}