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.

ApiExtension   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 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 55
loc 55
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 10 10 2
A __construct() 4 4 1
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 Api 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\ApiHelper;
15
16
/**
17
 * @author GeLo <[email protected]>
18
 */
19 View Code Duplication
class ApiExtension 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...
20
{
21
    /**
22
     * @var ApiHelper
23
     */
24
    private $apiHelper;
25
26
    /**
27
     * @param ApiHelper $apiHelper
28
     */
29 9
    public function __construct(ApiHelper $apiHelper)
30
    {
31 9
        $this->apiHelper = $apiHelper;
32 9
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 9
    public function getFunctions()
38
    {
39 9
        $functions = [];
40
41 9
        foreach ($this->getMapping() as $name => $method) {
42 9
            $functions[] = new \Twig_SimpleFunction($name, [$this, $method], ['is_safe' => ['html']]);
43 7
        }
44
45 9
        return $functions;
46
    }
47
48
    /**
49
     * @param object[] $objects
50
     *
51
     * @return string
52
     */
53 9
    public function render(array $objects)
54
    {
55 9
        return $this->apiHelper->render($objects);
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61 9
    public function getName()
62
    {
63 9
        return 'ivory_google_api';
64
    }
65
66
    /**
67
     * @return string[]
68
     */
69 9
    private function getMapping()
70
    {
71 9
        return ['ivory_google_api' => 'render'];
72
    }
73
}
74