GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

StaticMapExtension   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 3
dl 55
loc 55
ccs 15
cts 15
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getFunctions() 10 10 2
A render() 4 4 1
A getName() 4 4 1
A getMapping() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map bundle package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMapBundle\Twig;
13
14
use Ivory\GoogleMap\Helper\StaticMapHelper;
15
use Ivory\GoogleMap\Map;
16
17
/**
18
 * @author GeLo <[email protected]>
19
 */
20 View Code Duplication
class StaticMapExtension extends \Twig_Extension
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    /**
23
     * @var StaticMapHelper
24
     */
25
    private $staticMapHelper;
26
27
    /**
28
     * @param StaticMapHelper $staticMapHelper
29
     */
30 9
    public function __construct(StaticMapHelper $staticMapHelper)
31
    {
32 9
        $this->staticMapHelper = $staticMapHelper;
33 9
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 9
    public function getFunctions()
39
    {
40 9
        $functions = [];
41
42 9
        foreach ($this->getMapping() as $name => $method) {
43 9
            $functions[] = new \Twig_SimpleFunction($name, [$this, $method], ['is_safe' => ['html']]);
44 7
        }
45
46 9
        return $functions;
47
    }
48
49
    /**
50
     * @param Map $map
51
     *
52
     * @return string
53
     */
54 9
    public function render(Map $map)
55
    {
56 9
        return $this->staticMapHelper->render($map);
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 9
    public function getName()
63
    {
64 9
        return 'ivory_google_map_static';
65
    }
66
67
    /**
68
     * @return string[]
69
     */
70 9
    private function getMapping()
71
    {
72 9
        return ['ivory_google_map_static' => 'render'];
73
    }
74
}
75