Test Failed
Push — master ( ab76be...ac2d3a )
by Julien
04:26
created

Errors::unauthorizedAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * This file is part of the Zemit Framework.
5
 *
6
 * (c) Zemit Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zemit\Mvc\Controller;
13
14
use Phalcon\Http\ResponseInterface;
15
16
/**
17
 * Default Error Actions
18
 */
19
trait Errors
20
{
21
    abstract public function setStatusCode(int $code, ?string $message = null): ResponseInterface;
22
    
23
    /**
24
     * Http Status Code - Generic
25
     * error
26
     */
27
    public function errorAction(?int $code = null, ?string $message = null): void
28
    {
29
        $this->setStatusCode($code, $message);
0 ignored issues
show
Bug introduced by
It seems like $code can also be of type null; however, parameter $code of Zemit\Mvc\Controller\Errors::setStatusCode() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

29
        $this->setStatusCode(/** @scrutinizer ignore-type */ $code, $message);
Loading history...
30
    }
31
    
32
    /**
33
     * Http Status Code 400
34
     * bad-request
35
     */
36
    public function badRequestAction() : void
37
    {
38
        $this->setStatusCode(400);
39
    }
40
    
41
    /**
42
     * Http Status Code 401
43
     * unauthorized
44
     */
45
    public function unauthorizedAction(): void
46
    {
47
        $this->setStatusCode(401);
48
    }
49
    
50
    /**
51
     * Http Status Code 403
52
     * forbidden
53
     */
54
    public function forbiddenAction(): void
55
    {
56
        $this->setStatusCode(403);
57
    }
58
    
59
    /**
60
     * Http Status Code 404
61
     * not-found
62
     */
63
    public function notFoundAction(): void
64
    {
65
        $this->setStatusCode(404);
66
    }
67
    
68
    /**
69
     * Http Status Code 500
70
     * fatal
71
     */
72
    public function fatalAction() : void
73
    {
74
        $this->setStatusCode(500);
75
    }
76
    
77
    /**
78
     * Http Status Code 503
79
     * maintenance
80
     */
81
    public function maintenanceAction() : void
82
    {
83
        $this->setStatusCode(503);
84
    }
85
}
86