Completed
Push — master ( 465cbd...e0d13e )
by Marco
06:44 queued 11s
created

Status200   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 13
c 0
b 0
f 0
ccs 6
cts 8
cp 0.75
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A consolidate() 0 11 2
1
<?php namespace Comodojo\Dispatcher\Response\Preprocessor;
2
3
/**
4
 * Status: OK
5
 *
6
 * @package     Comodojo Dispatcher
7
 * @author      Marco Giovinazzi <[email protected]>
8
 * @author      Marco Castiello <[email protected]>
9
 * @license     MIT
10
 *
11
 * LICENSE:
12
 *
13
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
 * THE SOFTWARE.
20
 */
21
22
class Status200 extends AbstractPreprocessor {
23
24 1
    public function consolidate() {
25
26 1
        $this->response->getHeaders()->set('Content-Length', $this->response->getContent()->length());
27
28 1
        $type = $this->response->getContent()->type();
29 1
        $charset = $this->response->getContent()->charset();
30
31 1
        if (empty($charset)) {
32
            $this->response->getHeaders()->set("Content-type", strtolower($type));
33
        } else {
34 1
            $this->response->getHeaders()->set("Content-type", strtolower($type)."; charset=".$charset);
35
        }
36
37 1
    }
38
39
}
40