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

Response::controller()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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