Completed
Push — master ( b015a1...0e1003 )
by Abdelrahman
49:45
created

RouteUrlGenerator::addQueryString()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 4
nop 2
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Cortex Foundation Module.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Cortex Foundation Module
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
declare(strict_types=1);
17
18
namespace Cortex\Foundation\Overrides\Illuminate\Routing;
19
20
use Illuminate\Routing\RouteUrlGenerator as BaseRouteUrlGenerator;
21
22
class RouteUrlGenerator extends BaseRouteUrlGenerator
23
{
24
    /**
25
     * Add a query string to the URI.
26
     *
27
     * @param string $uri
28
     * @param array  $parameters
29
     *
30
     * @return mixed|string
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use string.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
31
     */
32
    protected function addQueryString($uri, array $parameters)
33
    {
34
        // If the URI has a fragment we will move it to the end of this URI since it will
35
        // need to come after any query string that may be added to the URL else it is
36
        // not going to be available. We will remove it then append it back on here.
37
        if (! is_null($fragment = parse_url($uri, PHP_URL_FRAGMENT))) {
38
            $uri = preg_replace('/#.*/', '', $uri);
39
        }
40
41
        $uri .= '/'.$this->getRouteQueryString($parameters);
42
43
        return is_null($fragment) ? $uri : $uri."#{$fragment}";
44
    }
45
}
46