Code Duplication    Length = 9-22 lines in 3 locations

php/Requests/AbstractRequest.php 3 locations

@@ 89-110 (lines=22) @@
86
                $result = json_decode($result->body, true);
87
                error_log('Error 400 - ' . print_r($result, true));
88
                break;
89
            case 401:
90
91
                if($result == "Unauthorized")
92
                {
93
                    error_log("Error 401: Unauthorized");
94
                }
95
                else
96
                {
97
                    $result = json_decode($result->body, true);
98
99
                    if(is_array($result) && $result['error'] == 'length')
100
                    {
101
102
                    }
103
                    else
104
                    {
105
                        error_log('Error 401 - ' . print_r($result, true));
106
                    }
107
                }
108
109
110
                break;
111
            case 404:
112
113
@@ 111-124 (lines=14) @@
108
109
110
                break;
111
            case 404:
112
113
114
                error_log('Error 404 - ' . print_r($result, true));
115
                $result = json_decode($result->body, true);
116
117
                if(array_key_exists('error', $result) && $result['error'] == 'post_blocked')
118
                {
119
                    header('HTTP/1.0 404 Not Found');
120
                    include('error-pages/404.php');
121
                    exit();
122
                }
123
124
                break;
125
			case 477:
126
                $result = json_decode($result->body, true);
127
                error_log('Error 477 - ' . print_r($result, true));
@@ 142-150 (lines=9) @@
139
                $result = json_decode($result->body, true);
140
                header('location:'.$_SERVER['PHP_SELF']);
141
                break;
142
            case 503:
143
                error_log('Error 503 - ' . print_r($result, true));
144
                $result = json_decode($result->body, true);
145
146
                if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable')
147
                {
148
                    header('location:'.$_SERVER['PHP_SELF']); 
149
                }
150
                break;
151
            default:
152
                error_log('Error '.$result->status_code.' - unknown error');
153
                $result = json_decode($result->body, true);