absences_StatisticsEditor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 54.69 %

Coupling/Cohesion

Components 0
Dependencies 8

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 8
dl 35
loc 64
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 1
B addFields() 25 25 2
A addButtons() 10 10 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
 * OVIDENTIA http://www.ovidentia.org                                   *
4
 ************************************************************************
5
 * Copyright (c) 2003 by CANTICO ( http://www.cantico.fr )              *
6
 *                                                                      *
7
 * This file is part of Ovidentia.                                      *
8
 *                                                                      *
9
 * Ovidentia is free software; you can redistribute it and/or modify    *
10
 * it under the terms of the GNU General Public License as published by *
11
 * the Free Software Foundation; either version 2, or (at your option)  *
12
 * any later version.													*
13
 *																		*
14
 * This program is distributed in the hope that it will be useful, but  *
15
 * WITHOUT ANY WARRANTY; without even the implied warranty of			*
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.					*
17
 * See the  GNU General Public License for more details.				*
18
 *																		*
19
 * You should have received a copy of the GNU General Public License	*
20
 * along with this program; if not, write to the Free Software			*
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,*
22
 * USA.																	*
23
************************************************************************/
24
25
26
bab_Widgets()->includePhpClass('Widget_Form');
27
28
29
class absences_StatisticsEditor extends Widget_Form
30
{
31
32
	public function __construct()
33
	{
34
		$W = bab_Widgets();
35
36
		parent::__construct(null, $W->VBoxLayout()->setVerticalSpacing(1,'em'));
37
38
39
		$this->setName('filter');
40
		$this->addClass('widget-bordered');
41
		$this->addClass('BabLoginMenuBackground');
42
		$this->addClass('widget-centered');
43
		$this->setHiddenValue('tg', 'addon/absences/statistics');
44
		$this->setHiddenValue('idx', 'types');
45
		$this->colon();
46
47
		$this->setCanvasOptions($this->Options()->width(70,'em'));
0 ignored issues
show
Bug introduced by
It seems like $this->Options()->width(70, 'em') targeting Widget_CanvasOptions::width() can also be of type double; however, Widget_Item::setCanvasOptions() does only seem to accept object<Widget_CanvasOptions>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
48
49
		$this->addFields();
50
51
		$this->addButtons();
52
	}
53
54
55
56 View Code Duplication
	protected function addFields()
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...
57
	{
58
		global $babDB;
59
		$W = bab_Widgets();
60
		
61
		require_once dirname(__FILE__).'/organization.class.php';
62
		$resOrganization = new absences_OrganizationIterator();
63
64
		$orgaSelect = $W->Select();
65
		$orgaSelect->addOption('','');
66
67
		foreach ($resOrganization as $organization) {
68
			$orgaSelect->addOption($organization->id, $organization->name);
69
		}
70
71
		$this->addItem(
72
			$W->LabelledWidget(
73
				absences_translate('Organization'),
74
				$orgaSelect,
75
				'organization'
76
			)
77
		);
78
79
80
	}
81
82 View Code Duplication
	protected function addButtons()
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...
83
	{
84
		$W = bab_Widgets();
85
86
		$button = $W->FlowItems(
87
			$W->SubmitButton()->setName('export')->setLabel(absences_translate('Export'))
88
		)->setSpacing(1,'em');
89
90
		$this->addItem($button);
91
	}
92
}