ResponseTrait::getPhrases()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 91
Code Lines 89

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 89
nc 1
nop 0
dl 0
loc 91
ccs 0
cts 91
cp 0
crap 2
rs 8.24
c 1
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * This file is part of the Phalcon Framework.
5
 *
6
 * (c) Phalcon 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
declare(strict_types=1);
13
14
namespace Phalcon\Http\Message\Traits;
15
16
/**
17
 * Trait ResponseTrait
18
 */
19
trait ResponseTrait
20
{
21
    /**
22
     * Returns the list of status codes available
23
     */
24
    private function getPhrases(): array
25
    {
26
        return [
27
            100 => 'Continue',                                         // Information - RFC 7231, 6.2.1
28
            101 => 'Switching Protocols',                              // Information - RFC 7231, 6.2.2
29
            102 => 'Processing',                                       // Information - RFC 2518, 10.1
30
            103 => 'Early Hints',
31
            200 => 'OK',                                               // Success - RFC 7231, 6.3.1
32
            201 => 'Created',                                          // Success - RFC 7231, 6.3.2
33
            202 => 'Accepted',                                         // Success - RFC 7231, 6.3.3
34
            203 => 'Non-Authoritative Information',                    // Success - RFC 7231, 6.3.4
35
            204 => 'No Content',                                       // Success - RFC 7231, 6.3.5
36
            205 => 'Reset Content',                                    // Success - RFC 7231, 6.3.6
37
            206 => 'Partial Content',                                  // Success - RFC 7233, 4.1
38
            207 => 'Multi-status',                                     // Success - RFC 4918, 11.1
39
            208 => 'Already Reported',                                 // Success - RFC 5842, 7.1
40
            218 => 'This is fine',                                     // Unofficial - Apache Web Server
41
            419 => 'Page Expired',                                     // Unofficial - Laravel Framework
42
            226 => 'IM Used',                                          // Success - RFC 3229, 10.4.1
43
            300 => 'Multiple Choices',                                 // Redirection - RFC 7231, 6.4.1
44
            301 => 'Moved Permanently',                                // Redirection - RFC 7231, 6.4.2
45
            302 => 'Found',                                            // Redirection - RFC 7231, 6.4.3
46
            303 => 'See Other',                                        // Redirection - RFC 7231, 6.4.4
47
            304 => 'Not Modified',                                     // Redirection - RFC 7232, 4.1
48
            305 => 'Use Proxy',                                        // Redirection - RFC 7231, 6.4.5
49
            306 => 'Switch Proxy',                                     // Redirection - RFC 7231, 6.4.6 (Deprecated)
50
            307 => 'Temporary Redirect',                               // Redirection - RFC 7231, 6.4.7
51
            308 => 'Permanent Redirect',                               // Redirection - RFC 7538, 3
52
            400 => 'Bad Request',                                      // Client Error - RFC 7231, 6.5.1
53
            401 => 'Unauthorized',                                     // Client Error - RFC 7235, 3.1
54
            402 => 'Payment Required',                                 // Client Error - RFC 7231, 6.5.2
55
            403 => 'Forbidden',                                        // Client Error - RFC 7231, 6.5.3
56
            404 => 'Not Found',                                        // Client Error - RFC 7231, 6.5.4
57
            405 => 'Method Not Allowed',                               // Client Error - RFC 7231, 6.5.5
58
            406 => 'Not Acceptable',                                   // Client Error - RFC 7231, 6.5.6
59
            407 => 'Proxy Authentication Required',                    // Client Error - RFC 7235, 3.2
60
            408 => 'Request Time-out',                                 // Client Error - RFC 7231, 6.5.7
61
            409 => 'Conflict',                                         // Client Error - RFC 7231, 6.5.8
62
            410 => 'Gone',                                             // Client Error - RFC 7231, 6.5.9
63
            411 => 'Length Required',                                  // Client Error - RFC 7231, 6.5.10
64
            412 => 'Precondition Failed',                              // Client Error - RFC 7232, 4.2
65
            413 => 'Request Entity Too Large',                         // Client Error - RFC 7231, 6.5.11
66
            414 => 'Request-URI Too Large',                            // Client Error - RFC 7231, 6.5.12
67
            415 => 'Unsupported Media Type',                           // Client Error - RFC 7231, 6.5.13
68
            416 => 'Requested range not satisfiable',                  // Client Error - RFC 7233, 4.4
69
            417 => 'Expectation Failed',                               // Client Error - RFC 7231, 6.5.14
70
            418 => "I'm a teapot",                                     // Client Error - RFC 7168, 2.3.3
71
            420 => 'Method Failure',                                   // Unofficial - Spring Framework
72
            421 => 'Misdirected Request',
73
            422 => 'Unprocessable Entity',                             // Client Error - RFC 4918, 11.2
74
            423 => 'Locked',                                           // Client Error - RFC 4918, 11.3
75
            424 => 'Failed Dependency',                                // Client Error - RFC 4918, 11.4
76
            425 => 'Unordered Collection',
77
            426 => 'Upgrade Required',                                 // Client Error - RFC 7231, 6.5.15
78
            428 => 'Precondition Required',                            // Client Error - RFC 6585, 3
79
            429 => 'Too Many Requests',                                // Client Error - RFC 6585, 4
80
            431 => 'Request Header Fields Too Large',                  // Client Error - RFC 6585, 5
81
            440 => 'Login Time-out',                                   // Unofficial - IIS
82
            444 => 'No Response',                                      // Unofficial - nginx
83
            449 => 'Retry With',                                       // Unofficial - IIS
84
            494 => 'Request header too large',                         // Unofficial - nginx
85
            495 => 'SSL Certificate Error',                            // Unofficial - nginx
86
            496 => 'SSL Certificate Required',                         // Unofficial - nginx
87
            497 => 'HTTP Request Sent to HTTPS Port',                  // Unofficial - nginx
88
            499 => 'Client Closed Request',                            // Unofficial - nginx
89
            450 => 'Blocked by Windows Parental Controls (Microsoft)', // Unofficial - nginx
90
            451 => 'Unavailable For Legal Reasons',                    // Client Error - RFC 7725, 3
91
            498 => 'Invalid Token (Esri)',                             // Unofficial - ESRI
92
            500 => 'Internal Server Error',                            // Server Error - RFC 7231, 6.6.1
93
            501 => 'Not Implemented',                                  // Server Error - RFC 7231, 6.6.2
94
            502 => 'Bad Gateway',                                      // Server Error - RFC 7231, 6.6.3
95
            503 => 'Service Unavailable',                              // Server Error - RFC 7231, 6.6.4
96
            504 => 'Gateway Time-out',                                 // Server Error - RFC 7231, 6.6.5
97
            505 => 'HTTP Version not supported',                       // Server Error - RFC 7231, 6.6.6
98
            506 => 'Variant Also Negotiates',                          // Server Error - RFC 2295, 8.1
99
            507 => 'Insufficient Storage',                             // Server Error - RFC 4918, 11.5
100
            508 => 'Loop Detected',                                    // Server Error - RFC 5842, 7.2
101
            509 => 'Bandwidth Limit Exceeded',                         // Unofficial - Apache/cPanel
102
            510 => 'Not Extended',                                     // Server Error - RFC 2774, 7
103
            511 => 'Network Authentication Required',                  // Server Error - RFC 6585, 6
104
            520 => 'Unknown Error',                                    // Unofficial - Cloudflare
105
            521 => 'Web Server Is Down',                               // Unofficial - Cloudflare
106
            522 => 'Connection Timed Out',                             // Unofficial - Cloudflare
107
            523 => 'Origin Is Unreachable',                            // Unofficial - Cloudflare
108
            524 => 'A Timeout Occurred',                               // Unofficial - Cloudflare
109
            525 => 'SSL Handshake Failed',                             // Unofficial - Cloudflare
110
            526 => 'Invalid SSL Certificate',                          // Unofficial - Cloudflare
111
            527 => 'Railgun Error',                                    // Unofficial - Cloudflare
112
            530 => 'Origin DNS Error',                                 // Unofficial - Cloudflare
113
            598 => 'Network read timeout error',                       // Unofficial
114
            599 => 'Network Connect Timeout Error'                     // Server Error - RFC 6585, 6
115
        ];
116
    }
117
}
118