Total Complexity | 5 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class Storekeeper |
||
11 | { |
||
12 | private Repository $repository; |
||
13 | |||
14 | private State $state; |
||
15 | |||
16 | public function __construct(Repository $repository, State $state) |
||
17 | { |
||
18 | $this->repository = $repository; |
||
19 | $this->state = $state; |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * Add a new route |
||
24 | * |
||
25 | * @param string $method |
||
26 | * @param string $path |
||
27 | * @param Closure|string|array $controller |
||
28 | * @param string|null $name |
||
29 | */ |
||
30 | public function add(string $method, string $path, $controller, ?string $name = null): void |
||
31 | { |
||
32 | $this->repository->save( |
||
33 | $method, |
||
34 | $this->state->getPrefix() . $path, |
||
35 | $controller, |
||
36 | $name, |
||
37 | $this->state->getMiddleware(), |
||
38 | $this->state->getDomain() |
||
39 | ); |
||
40 | } |
||
41 | |||
42 | public function getState(): State |
||
43 | { |
||
44 | return $this->state; |
||
45 | } |
||
46 | |||
47 | public function setState(State $state): void |
||
48 | { |
||
49 | $this->state = $state; |
||
50 | } |
||
51 | |||
52 | public function getRepository(): Repository |
||
55 | } |
||
56 | } |
||
57 |