These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\AdminBundle\Twig; |
||
4 | |||
5 | use Kunstmaan\AdminBundle\Helper\DomainConfigurationInterface; |
||
6 | |||
7 | class MultiDomainAdminTwigExtension extends \Twig_Extension |
||
8 | { |
||
9 | /** |
||
10 | * @var DomainConfigurationInterface |
||
11 | */ |
||
12 | private $domainConfiguration; |
||
13 | |||
14 | public function __construct(DomainConfigurationInterface $domainConfiguration) |
||
15 | { |
||
16 | $this->domainConfiguration = $domainConfiguration; |
||
17 | } |
||
18 | |||
19 | |||
20 | /** |
||
21 | * Get Twig functions defined in this extension. |
||
22 | * |
||
23 | * @return array |
||
0 ignored issues
–
show
|
|||
24 | */ |
||
25 | View Code Duplication | public function getFunctions() |
|
26 | { |
||
27 | return array( |
||
28 | new \Twig_SimpleFunction('multidomain_widget', array($this, 'renderWidget'), array('needs_environment' => true, 'is_safe' => array('html'))), |
||
29 | new \Twig_SimpleFunction('is_multidomain_site', array($this, 'isMultiDomainSite')), |
||
30 | new \Twig_SimpleFunction('get_switched_host', array($this, 'getSwitchedHost')), |
||
31 | new \Twig_SimpleFunction('switched_host_is_current', array($this, 'switchedHostIsCurrent')), |
||
32 | ); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Render multidomain switcher widget. |
||
37 | * |
||
38 | * @param \Twig_Environment $env |
||
39 | * @param array $locales The locales |
||
0 ignored issues
–
show
There is no parameter named
$locales . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not.
Loading history...
|
|||
40 | * @param string $route The route |
||
41 | * @param array $parameters The route parameters |
||
42 | * |
||
43 | * @return string |
||
44 | */ |
||
45 | View Code Duplication | public function renderWidget(\Twig_Environment $env, $route, array $parameters = array()) |
|
0 ignored issues
–
show
This method 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...
|
|||
46 | { |
||
47 | $template = $env->loadTemplate( |
||
48 | "@KunstmaanAdmin/MultiDomainAdminTwigExtension/widget.html.twig" |
||
49 | ); |
||
50 | |||
51 | return $template->render( |
||
52 | array_merge( |
||
53 | $parameters, |
||
54 | array( |
||
55 | 'hosts' => $this->getAdminDomainHosts(), |
||
56 | 'route' => $route |
||
57 | ) |
||
58 | ) |
||
59 | ); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Check if site is multiDomain |
||
64 | * |
||
65 | * @return bool |
||
66 | */ |
||
67 | public function isMultiDomainSite() |
||
68 | { |
||
69 | return $this->domainConfiguration->isMultiDomainHost(); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return string |
||
74 | */ |
||
75 | public function getSwitchedHost() |
||
76 | { |
||
77 | return $this->domainConfiguration->getHostSwitched(); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @return string |
||
0 ignored issues
–
show
|
|||
82 | */ |
||
83 | public function switchedHostIsCurrent() |
||
84 | { |
||
85 | return $this->domainConfiguration->getHost() == $this->getSwitchedHost()['host']; |
||
86 | } |
||
87 | |||
88 | public function getAdminDomainHosts() |
||
89 | { |
||
90 | return $this->domainConfiguration->getHosts(); |
||
91 | } |
||
92 | } |
||
93 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.