Completed
Push — 14.2 ( 5702a1...375f73 )
by Nathan
38:22
created

calendar_wizard_import_ical   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 70
Duplicated Lines 21.43 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 15
loc 70
rs 10
c 0
b 0
f 0
wmc 9
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A wizard_step50() 0 7 1
C wizard_step55() 15 37 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
 * EGroupware - Wizard for user CSV import
4
 *
5
 * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
6
 * @package calendar
7
 * @subpackage importexport
8
 * @link http://www.egroupware.org
9
 * @author Nathan Gray
10
 * @version $Id$
11
 */
12
13
use EGroupware\Api;
14
15
class calendar_wizard_import_ical
16
{
17
	/**
18
	* List of steps.  Key is the function, value is the translated title.
19
	*/
20
	public $steps;
21
22
	/**
23
	* List of eTemplates to use for each step.  You can override this with your own etemplates steps.
24
	*/
25
	protected $step_templates = array(
26
		'wizard_step55' => 'calendar.import.conditions'
27
	);
28
    /**
29
	 * constructor
30
	 */
31
	function __construct()
32
	{
33
		$this->steps = array(
34
			'wizard_step55' => lang('Edit conditions'),
35
		);
36
	}
37
38
	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
39
	{
40
		$result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv);
41
		$content['msg'] .= "\n*" ;
42
43
		return $result;
44
	}
45
46
	// Conditions
47
	function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv)
48
	{
49
		// return from step55
50
		if ($content['step'] == 'wizard_step55')
51
		{
52 View Code Duplication
			switch (array_search('pressed', $content['button']))
53
			{
54
				case 'next':
55
					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
56
				case 'previous' :
57
					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
58
				case 'finish':
59
					return 'wizard_finish';
60
				default :
61
					return $this->wizard_step55($content,$sel_options,$readonlys,$preserv);
62
			}
63
		}
64
		// init step30
65
		else
66
		{
67
			$content['text'] = $this->steps['wizard_step55'];
68
			$content['step'] = 'wizard_step55';
69 View Code Duplication
			if(!$content['skip_conflicts'] && array_key_exists('skip_conflicts', $content['plugin_options']))
70
			{
71
				$content['skip_conflicts'] = $content['plugin_options']['skip_conflicts'];
72
			}
73
			$preserv = $content;
74
			unset ($preserv['button']);
75
			
76
			// No real conditions, but we share a template
77
			$content['no_conditions'] = true;
78
79
			return $this->step_templates[$content['step']];
80
		}
81
82
		return $result;
0 ignored issues
show
Unused Code introduced by
return $result; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
83
	}
84
}
85