Completed
Push — v0_9 ( 7321a8...fbed1d )
by Vladimir
03:21
created

CanonicalUrl   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 6 1
A get() 0 7 1
1
<?php
2
3
namespace BZIon\Twig;
4
5
class CanonicalUrl
6
{
7
    /**
8
     * Build the canonical URL of a relative URL
9
     *
10
     * @param  string $relativeUrl
11
     * @return string The canonical URL
12
     */
13
    public function __invoke($relativeUrl)
14
    {
15
        $baseURL = \Service::getRequest()->getSchemeAndHttpHost();
16
17
        return $baseURL . $relativeUrl;
18
    }
19
20
    public static function get()
21
    {
22
        return new \Twig_SimpleFilter(
23
            'canonical',
24
            new self()
25
        );
26
    }
27
}