Passed
Branch main (7d5b4b)
by Sammy
16:06 queued 06:48
created

Response   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 4
A controller() 0 3 1
A method() 0 3 1
1
<?php
2
3
/**
4
* huppel konijntje huppel and wiebel
5
* Hommage to Grace Hopper, programmer & expert in *litteral* duck taping
6
***/
7
8
namespace HexMakina\Hopper;
9
10
class Response
11
{
12
    private string $controller;
13
    private string $method;
14
15
    public function __construct(Request $request)
16
    {
17
      $res = explode('::', $request->target());
18
19
      // if explode() returned false
20
      // or if the array doesn't have a second element (the method)
21
      // or if the array has more than 2 elements
22
      if ($res === false || !isset($res[1]) || isset($res[2])) {
23
          throw new RouterException('INVALID_TARGET_FORMAT');
24
      }
25
26
      $this->controller = $res[0];
27
      $this->method = $res[1];
28
    }
29
30
    public function controller()
31
    {
32
        return $this->controller;
33
    }
34
35
    public function method()
36
    {
37
        return $this->method;
38
    }
39
}
40