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

UrlModifyFunction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 5
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 1
A get() 0 4 1
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