Completed
Push — fm-support ( 624fa6...b0af51 )
by Konstantinos
09:12 queued 04:41
created

UrlModifyFunction::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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 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
    public static function get()
24
    {
25
        return new \Twig_SimpleFunction('url_modify', new self());
26
    }
27
}
28