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.
Completed
Pull Request — develop (#307)
by
unknown
02:41
created

LocaliseViewLanguage   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 84
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
c 1
b 0
f 0
lcom 1
cbo 0
dl 84
loc 84
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B display() 25 25 2
C addToolbar() 35 35 7

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
 * View to edit a language.
14
 *
15
 * @package     Extensions.Components
16
 * @subpackage  Localise
17
 *
18
 * @since       1.0
19
 */
20 View Code Duplication
class LocaliseViewLanguage extends JViewLegacy
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
	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
	public function display($tpl = null)
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
		$canDo = JHelperContent::getActions('com_localise', 'component');
72
73
		$user       = JFactory::getUser();
74
		$isNew      = empty($this->item->id);
75
		$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
76
77
		JToolbarHelper::title(
78
			JText::sprintf(
79
				'COM_LOCALISE_HEADER_MANAGER',
80
				$isNew ? JText::_('COM_LOCALISE_HEADER_LANGUAGE_NEW') : JText::_('COM_LOCALISE_HEADER_LANGUAGE_EDIT')
81
			),
82
			'icon-comments-2 langmanager'
83
		);
84
85
		// If not checked out, can save the item.
86
		if (!$checkedOut)
87
		{
88
			JToolbarHelper::apply('language.apply');
89
			JToolbarHelper::save('language.save');
90
		}
91
92
		JToolBarHelper::cancel('language.cancel', $isNew ? 'JTOOLBAR_CANCEL' : 'JTOOLBAR_CLOSE');
93
		JToolBarHelper::divider();
94
95
		if ($canDo->get('localise.create') && !$isNew)
96
		{
97
			JToolbarHelper::custom('language.copy', 'copy.png', 'copy.png', 'COM_LOCALISE_COPY_REF_TO_NEW_LANG', false);
98
			JToolBarHelper::divider();
99
		}
100
101
		JToolBarHelper::help('screen.language', true);
102
	}
103
}
104