Completed
Pull Request — master (#14)
by Andreas
02:51
created

GeolocationRenderer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 85
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A preRenderForm() 0 15 1
A getHttpRouter() 0 4 1
A setHttpRouter() 0 6 1
A getOptions() 0 4 1
A setOptions() 0 6 1
1
<?php
2
/**
3
 * Copyright Andreas Heigl <[email protected]>
4
 * 
5
 * Permission is hereby granted, free of charge, to any person obtaining a copy
6
 * of this software and associated documentation files (the "Software"), to deal
7
 * in the Software without restriction, including without limitation the rights
8
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the Software is
10
 * furnished to do so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be included in
13
 * all copies or substantial portions of the Software.
14
 * 
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIBILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
 * THE SOFTWARE.
22
 *
23
 * @author    Andreas Heigl<[email protected]>
24
 * @copyright Andreas Heigl
25
 * @license   http://www.opesource.org/licenses/mit-license.php MIT-License
26
 * @version   0.0
27
 * @since     29.07.13
28
 * @link      https://github.com/heiglandreas/OrgHeiglGeolocation
29
 */
30
31
namespace Org_Heigl\Geolocation\Renderer\Geolocation;
32
33
use Zend\View\Renderer\PhpRenderer as View;
34
use Zend\Mvc\Router\RouteInterface;
35
use Zend\Stdlib\AbstractOptions;
36
use Zend\EventManager\StaticEventManager;
37
use Zend\View\ViewEvent;
38
39
40
class GeolocationRenderer
41
{
42
    public function __construct()
43
    {
44
        $events = StaticEventManager::getInstance ();
45
46
        // Add event of authentication before dispatch
47
        $events->attach('Zend\View\View', ViewEvent::EVENT_RENDERER_POST, array(
48
            $this,
49
            'preRenderForm'
50
        ), 110 );
51
    }
52
    /**
53
     * @var \Zend\Mvc\Router\RouteInterface $httpRouter
54
     */
55
    protected $httpRouter = null;
56
57
    /**
58
     * @var \Zend\StdLib\AbstractOptions $options
59
     */
60
    protected $options = null;
61
62
    /**
63
     * Executed before the ZF2 view helper renders the element
64
     *
65
     * @param \Zend\View\ViewEvent $view
66
     */
67
    public function preRenderForm(ViewEvent $view)
68
    {
69
        $view = $view->getRenderer();
70
        $inlineScript = $view->plugin('inlineScript');
71
72
        $assetBaseUri = $this->getHttpRouter()->assemble(array(), array('name' => 'home'));
73
//        if ($this->getOptions()->isIncludeJquery()) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
74
//            $inlineScript->appendFile($assetBaseUri . '/lib/jquery/jquery.min.js');
75
//        }
76
//        if ($this->getOptions()->isIncludeLeaflet()) {
77
//            $inlineScript->appendFile($assetBaseUri . '/lib/leaflet/leaflet.min.js');
78
//        }
79
        $inlineScript->appendFile($assetBaseUri . '/js/geolocation.js');
80
        return $this;
81
    }
82
83
84
    /**
85
     * @return \Zend\Mvc\Router\RouteInterface
86
     */
87
    public function getHttpRouter()
88
    {
89
        return $this->httpRouter;
90
    }
91
92
    /**
93
     * @param \Zend\Mvc\Router\RouteInterface $httpRoute
0 ignored issues
show
Documentation introduced by
There is no parameter named $httpRoute. Did you maybe mean $httpRouter?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
94
     *
95
     * @return Renderer
96
     */
97
    public function setHttpRouter(RouteInterface $httpRouter)
98
    {
99
        $this->httpRouter = $httpRouter;
100
101
        return $this;
102
    }
103
104
    /**
105
     * @return \Zend\StdLib\AbstractOptions
106
     */
107
    public function getOptions()
108
    {
109
        return $this->options;
110
    }
111
112
    /**
113
     * @param \Zend\StdLib\AbstractOptions $options
114
     *
115
     * @return Renderer
116
     */
117
    public function setOptions(AbstractOptions $options = null)
118
    {
119
        $this->options = $options;
120
121
        return $this;
122
    }
123
124
}