forked from apivalk/apivalk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApivalk.php
More file actions
57 lines (45 loc) · 1.45 KB
/
Apivalk.php
File metadata and controls
57 lines (45 loc) · 1.45 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types=1);
namespace apivalk\apivalk;
use apivalk\apivalk\Http\Response\AbstractApivalkResponse;
use apivalk\apivalk\Middleware\MiddlewareStack;
use apivalk\apivalk\Http\Renderer\RendererInterface;
use apivalk\apivalk\Router\AbstractRouter;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
class Apivalk
{
/** @var ApivalkConfiguration */
private $configuration;
public function __construct(ApivalkConfiguration $apivalkConfiguration)
{
$this->configuration = $apivalkConfiguration;
if ($apivalkConfiguration->getExceptionHandler() !== null) {
set_exception_handler($apivalkConfiguration->getExceptionHandler());
}
}
public function run(): AbstractApivalkResponse
{
return $this->configuration->getRouter()->dispatch($this->configuration->getMiddlewareStack());
}
public function getMiddlewareStack(): MiddlewareStack
{
return $this->configuration->getMiddlewareStack();
}
public function getRenderer(): RendererInterface
{
return $this->configuration->getRenderer();
}
public function getRouter(): AbstractRouter
{
return $this->configuration->getRouter();
}
public function getContainer(): ?ContainerInterface
{
return $this->configuration->getContainer();
}
public function getLogger(): LoggerInterface
{
return $this->configuration->getLogger();
}
}