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

Status200::consolidate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
ccs 6
cts 8
cp 0.75
rs 9.4285
cc 2
eloc 7
nc 2
nop 0
crap 2.0625
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