Completed
Push — master ( 312098...b95ba9 )
by Nikolas
40:06
created

ExecuteResource   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A doGet() 0 4 1
A doPost() 0 4 1
A getExecutionResource() 0 6 1
1
<?php
2
namespace rtens\domin\delivery\web\adapters\curir\root;
3
4
use rtens\domin\delivery\web\adapters\curir\CurirBreadCrumbsTrail;
5
use rtens\domin\delivery\web\adapters\curir\CurirParameterReader;
6
use rtens\domin\delivery\web\resources\ExecutionResource;
7
use rtens\domin\delivery\web\WebApplication;
8
use watoki\curir\cookie\CookieStore;
9
use watoki\curir\delivery\WebRequest;
10
use watoki\curir\Resource;
11
12
class ExecuteResource extends Resource {
13
14
    const ACTION_ARG = '__action';
15
16
    /**
17
     * @param WebApplication $app <-
18
     * @param CookieStore $cookies <-
19
     * @param WebRequest $request <-
20
     * @param string $__action
21
     * @param bool $__force
22
     * @return string
23
     */
24
    public function doGet(WebApplication $app, CookieStore $cookies, WebRequest $request, $__action, $__force = false) {
25
        $execution = $this->getExecutionResource($app, $cookies, $request);
26
        return $execution->handleGet($__action, $__force);
27
    }
28
29
    /**
30
     * @param WebApplication $app <-
31
     * @param CookieStore $cookies <-
32
     * @param WebRequest $request <-
33
     * @param string $__action
34
     * @return string
35
     */
36
    public function doPost(WebApplication $app, CookieStore $cookies, WebRequest $request, $__action) {
37
        $execution = $this->getExecutionResource($app, $cookies, $request);
38
        return $execution->handlePost($__action);
39
    }
40
41
    private function getExecutionResource(WebApplication $app, CookieStore $cookies, WebRequest $request) {
42
        $app->prepare();
43
44
        $reader = new CurirParameterReader($request);
45
        return new ExecutionResource($app, $reader, new CurirBreadCrumbsTrail($reader, $cookies));
46
    }
47
}