SmartyFl   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 88
Duplicated Lines 47.73 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 42
loc 88
rs 10
c 0
b 0
f 0
wmc 10
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A addConfigDirPrepend() 14 14 3
A addPluginsDirPrepend() 14 14 3
A addTemplateDirPrepend() 14 14 3

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
//require_once('smarty/Smarty.class.php');
3
4
/**
5
 * Extended Smarty class
6
 *
7
 * @deprecated  Use Fwlib\Bridge\Smarty
8
 * @package		fwolflib
9
 * @subpackage	class.smarty-fl
10
 * @copyright	Copyright 2013, Fwolf
11
 * @author		Fwolf <[email protected]>
12
 * @license		http://www.gnu.org/licenses/lgpl.html LGPL v3
13
 * @since		2013-01-18
14
 */
15
class SmartyFl extends Smarty {
16
17
18
	/**
19
	 * constructor
20
	 */
21
	public function __construct () {
22
		parent::__construct();
23
24
        // Delimiter
25
		$this->left_delimiter = '{';
26
		$this->right_delimiter = '}';
27
28
		$this->use_sub_dirs = true;
29
30
	} // end of func __construct
31
32
33
	/**
34
	 * Prepend to config_dir array
35
	 *
36
	 * @param	string|array	$config_dir
37
	 * @param	string			$key
38
	 * @return	$this
39
	 */
40 View Code Duplication
	public function addConfigDirPrepend ($config_dir, $key = '') {
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...
41
		$ar_tpl = $this->getConfigDir();
42
		if (is_string($ar_tpl))
43
			$ar_tpl = array($ar_tpl);
44
45
		if (is_string($config_dir)) {
46
			$config_dir = array($key => $config_dir);
47
		}
48
49
		$ar_tpl = array_merge($config_dir, $ar_tpl);
50
		$this->setConfigDir($ar_tpl);
51
52
		return $this;
53
	} // end of func addConfigDirPrepend
54
55
56
	/**
57
	 * Prepend to plugins_dir array
58
	 *
59
	 * @param	string|array	$plugins_dir
60
	 * @param	string			$key
61
	 * @return	$this
62
	 */
63 View Code Duplication
	public function addPluginsDirPrepend ($plugins_dir, $key = '') {
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...
64
		$ar_tpl = $this->getPluginsDir();
65
		if (is_string($ar_tpl))
66
			$ar_tpl = array($ar_tpl);
67
68
		if (is_string($plugins_dir)) {
69
			$plugins_dir = array($key => $plugins_dir);
70
		}
71
72
		$ar_tpl = array_merge($plugins_dir, $ar_tpl);
73
		$this->setPluginsDir($ar_tpl);
74
75
		return $this;
76
	} // end of func addPluginsDirPrepend
77
78
79
	/**
80
	 * Prepend to template_dir array
81
	 *
82
	 * @param	string|array	$template_dir
83
	 * @param	string			$key
84
	 * @return	$this
85
	 */
86 View Code Duplication
	public function addTemplateDirPrepend ($template_dir, $key = '') {
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...
87
		$ar_tpl = $this->getTemplateDir();
88
		if (is_string($ar_tpl))
89
			$ar_tpl = array($ar_tpl);
90
91
		if (is_string($template_dir)) {
92
			$template_dir = array($key => $template_dir);
93
		}
94
95
		$ar_tpl = array_merge($template_dir, $ar_tpl);
96
		$this->setTemplateDir($ar_tpl);
97
98
		return $this;
99
	} // end of func addTemplateDirPrepend
100
101
102
} // end of class SmartyFl
103
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
104