Completed
Push — 4.0 ( 7855d8...1b9fbe )
by Marco
11:07
created

Status501::consolidate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 7

Duplication

Lines 18
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 18
loc 18
rs 9.4285
cc 2
eloc 7
nc 2
nop 0
1
<?php namespace Comodojo\Dispatcher\Output\HttpStatus;
2
3
/**
4
 * Status: Not implemented
5
 *
6
 * @package     Comodojo Dispatcher
7
 * @author      Marco Giovinazzi <[email protected]>
8
 * @author      Marco Castiello <[email protected]>
9
 * @license     GPL-3.0+
10
 *
11
 * LICENSE:
12
 *
13
 * This program is free software: you can redistribute it and/or modify
14
 * it under the terms of the GNU Affero General Public License as
15
 * published by the Free Software Foundation, either version 3 of the
16
 * License, or (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU Affero General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU Affero General Public License
24
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
 */
26
27 View Code Duplication
class Status501 extends AbstractHttpStatus {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
29
    public function consolidate() {
30
31
        // An Allow Header should be prvided from DispatcherException
32
        $allowed = $this->response()->headers()->get('Allow');
33
34
        if ( is_null($allowed) ) {
35
36
            header('Method not implemented', true, 501);
37
38
        } else {
39
40
            header("Allow: $allowed", true, 501);
41
42
            $this->response()->headers()->remove('Allow');
0 ignored issues
show
Bug introduced by
The method remove() does not seem to exist on object<Comodojo\Dispatcher\Response\Headers>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
44
        }
45
46
    }
47
48
}
49