Response   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A redirect() 0 9 3
1
<?php
2
3
namespace Ffcms\Core\Network;
4
5
use Ffcms\Core\App;
6
use Ffcms\Core\Helper\Type\Str;
7
use Symfony\Component\HttpFoundation\RedirectResponse as FoundationRedirect;
8
use Symfony\Component\HttpFoundation\Response as FoundationResponse;
9
10
/**
11
 * Class Response. Basic implementation of httpfoundation.response class.
12
 * @package Ffcms\Core\Network
13
 */
14
class Response extends FoundationResponse
15
{
16
    /**
17
     * Fast redirect in web environment
18
     * @param string $to
19
     * @param bool $full
20
     */
21
    public function redirect($to, $full = false)
22
    {
23
        $to = trim($to, '/');
24
        if (!$full && !Str::startsWith(App::$Alias->baseUrl, $to)) {
25
            $to = App::$Alias->baseUrl . '/' . $to;
26
        }
27
        $redirect = new FoundationRedirect($to);
28
        $redirect->send();
29
        exit('Redirecting to ' . $to . ' ...');
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
30
    }
31
}
32