Passed
Push — master ( 035a69...ef3bdc )
by Kirill
03:22
created

TestController::notFound()   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
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Tests\Router\Fixtures;
13
14
use Spiral\Core\Exception\ControllerException;
15
use Laminas\Diactoros\Response;
16
17
class TestController
18
{
19
    public function index()
20
    {
21
        return 'hello world';
22
    }
23
24
    public function test()
25
    {
26
        return 'hello world';
27
    }
28
29
    public function id(string $id)
30
    {
31
        return $id;
32
    }
33
34
    public function echo(): void
35
    {
36
        ob_start();
37
        echo 'echoed';
38
    }
39
40
    public function err(): void
41
    {
42
        throw new \Error('error.controller');
43
    }
44
45
    public function rsp()
46
    {
47
        $r = new Response();
48
        $r->getBody()->write('rsp');
49
50
        echo 'buf';
51
52
        return $r;
53
    }
54
55
    public function json()
56
    {
57
        return [
58
            'status' => 301,
59
            'msg'    => 'redirect'
60
        ];
61
    }
62
63
    public function forbidden(): void
64
    {
65
        throw new ControllerException('', ControllerException::FORBIDDEN);
66
    }
67
68
    public function notFound(): void
69
    {
70
        throw new ControllerException('', ControllerException::NOT_FOUND);
71
    }
72
73
    public function weird(): void
74
    {
75
        throw new ControllerException('', 99);
76
    }
77
78
    public function postTarget()
79
    {
80
        return 'POST';
81
    }
82
83
    public function deleteTarget()
84
    {
85
        return 'DELETE';
86
    }
87
}
88