Commands::redirect()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Controller commands
4
 * User: moyo
5
 * Date: 2018/6/11
6
 * Time: 10:14 AM
7
 */
8
9
namespace Carno\Web\Chips\Controller;
10
11
use Carno\HTTP\Standard\Response;
12
13
trait Commands
14
{
15
    /**
16
     * @param string $target
17
     * @param bool $permanently
18
     * @return Response
19
     */
20
    final public function redirect(string $target, bool $permanently = false) : Response
21
    {
22
        return $this->response = new Response($permanently ? 301 : 302, ['Location' => $target]);
0 ignored issues
show
Bug Best Practice introduced by
The property response does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
23
    }
24
}
25