Completed
Push — master ( 511324...c26f0f )
by Konstantinos
08:12
created

UrlModifyFunction::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 9
ccs 0
cts 0
cp 0
rs 9.6666
c 1
b 0
f 1
cc 1
eloc 6
nc 1
nop 1
crap 2
1
<?php
2
3
namespace BZIon\Twig;
4
5
class UrlModifyFunction
6
{
7
    /**
8
     * Modify the current page URL
9
     *
10
     * @param  array  $parameters An array of parameters to add/modify in the request
11
     * @return string The HTML link
12
     */
13
    public static function __invoke(array $parameters) {
14
        $attributes = \Service::getRequest()->attributes;
15
        $query = \Service::getRequest()->query;
16
17
        return \Service::getGenerator()->generate(
18
            $attributes->get('_route'),
19
            $parameters + $attributes->get('_route_params') + $query->all()
20
        );
21
    }
22
23 1
    public static function get()
24
    {
25 1
        return new \Twig_SimpleFunction('url_modify', new self());
26
    }
27
}
28