LeftAndMain_HTTPResponse   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setIsFinished() 0 3 1
A isFinished() 0 3 2
A cloneFrom() 0 14 3
1
<?php
2
3
namespace LeKoala\Admini;
4
5
use SilverStripe\Control\HTTPResponse;
6
7
/**
8
 * Allow overriding finished state for faux redirects.
9
 */
10
class LeftAndMain_HTTPResponse extends HTTPResponse
11
{
12
13
    protected $isFinished = false;
14
15
    public function isFinished()
16
    {
17
        return (parent::isFinished() || $this->isFinished);
18
    }
19
20
    public function setIsFinished($bool)
21
    {
22
        $this->isFinished = $bool;
23
    }
24
25
    public static function cloneFrom(HTTPResponse $response): LeftAndMain_HTTPResponse
26
    {
27
        $newResponse = new LeftAndMain_HTTPResponse(
28
            $response->getBody(),
29
            $response->getStatusCode(),
30
            $response->getStatusDescription()
31
        );
32
        foreach ($response->getHeaders() as $k => $v) {
33
            $newResponse->addHeader($k, $v);
34
        }
35
        foreach ($response->getHeaders() as $k => $v) {
36
            $newResponse->addHeader($k, $v);
37
        }
38
        return $newResponse;
39
    }
40
}
41