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.

LocaliseViewTranslation   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 83
Duplicated Lines 30.12 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 25
loc 83
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A display() 25 25 2
A addToolbar() 0 34 5

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
 * @package     Com_Localise
4
 * @subpackage  views
5
 *
6
 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
7
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
8
 */
9
10
defined('_JEXEC') or die;
11
12
/**
13
 * Translation View class for the Localise component
14
 *
15
 * @package     Extensions.Components
16
 * @subpackage  Localise
17
 *
18
 * @since       1.0
19
 */
20
class LocaliseViewTranslation extends JViewLegacy
21
{
22
	protected $state;
23
24
	protected $item;
25
26
	protected $form;
27
28
	/**
29
	 * Display the view
30
	 *
31
	 * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
32
	 *
33
	 * @return  void
34
	 */
35 View Code Duplication
	public function display($tpl = null)
0 ignored issues
show
Duplication introduced by
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...
36
	{
37
		jimport('joomla.client.helper');
38
39
		// Get the data
40
		$this->state   = $this->get('State');
41
		$this->item    = $this->get('Item');
42
		$this->form    = $this->get('Form');
43
		$this->formftp = $this->get('FormFtp');
44
		$this->ftp     = JClientHelper::setCredentialsFromRequest('ftp');
45
46
		// Check for errors.
47
		if (count($errors = $this->get('Errors')))
48
		{
49
			JError::raiseError(500, implode("\n", $errors));
50
51
			return false;
52
		}
53
54
		// Set the toolbar
55
		$this->addToolbar();
56
57
		// Display the view
58
		parent::display($tpl);
59
	}
60
61
	/**
62
	 * Add the page title and toolbar.
63
	 *
64
	 * @return  void
65
	 *
66
	 * @since   1.6
67
	 */
68
	protected function addToolbar()
69
	{
70
		JFactory::getApplication()->input->set('hidemainmenu', true);
71
72
		$user		= JFactory::getUser();
73
		$checkedOut	= !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
74
75
		if ($this->state->get('translation.filename') == 'joomla')
76
		{
77
			$filename = $this->state->get('translation.tag') . '.ini';
78
		}
79
		else
80
		{
81
			$filename = $this->state->get('translation.tag') . '.' . $this->state->get('translation.filename') . '.ini';
82
		}
83
84
		JToolbarHelper::title(
85
			JText::sprintf(
86
				'COM_LOCALISE_HEADER_MANAGER',
87
				JText::sprintf($this->item->exists ? 'COM_LOCALISE_HEADER_TRANSLATION_EDIT' : 'COM_LOCALISE_HEADER_TRANSLATION_NEW', $filename)
88
			),
89
			'comments-2 langmanager'
90
		);
91
92
		if (!$checkedOut)
93
		{
94
			JToolbarHelper::apply('translation.apply');
95
			JToolbarHelper::save('translation.save');
96
		}
97
98
		JToolbarHelper::cancel('translation.cancel');
99
		JToolBarHelper::divider();
100
		JToolBarHelper::help('screen.translation', true);
101
	}
102
}
103