Conditions | 7 |
Paths | 10 |
Total Lines | 51 |
Code Lines | 33 |
Lines | 17 |
Ratio | 33.33 % |
Changes | 10 | ||
Bugs | 1 | Features | 2 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
90 | public function configure($selfedit = 'false') |
||
91 | { |
||
92 | $this->selfedit = $selfedit; |
||
93 | |||
94 | if ($selfedit == 'true') { |
||
95 | $this->moufManager = MoufManager::getMoufManager(); |
||
96 | } else { |
||
97 | $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
||
98 | } |
||
99 | |||
100 | // Let's start by performing basic checks about the instances we assume to exist. |
||
101 | if (!$this->moufManager->instanceExists('dbalConnection')) { |
||
102 | $this->displayErrorMsg("The TDBM install process assumes your database connection instance is already created, and that the name of this instance is 'dbalConnection'. Could not find the 'dbalConnection' instance."); |
||
103 | |||
104 | return; |
||
105 | } |
||
106 | |||
107 | if (!$this->moufManager->instanceExists('noCacheService')) { |
||
108 | $this->displayErrorMsg("The TDBM install process assumes that a cache instance named 'noCacheService' exists. Could not find the 'noCacheService' instance."); |
||
109 | |||
110 | return; |
||
111 | } |
||
112 | |||
113 | $this->daoNamespace = $this->moufManager->getVariable('tdbmDefaultDaoNamespace_tdbmService'); |
||
114 | $this->beanNamespace = $this->moufManager->getVariable('tdbmDefaultBeanNamespace_tdbmService'); |
||
115 | |||
116 | View Code Duplication | if ($this->daoNamespace == null && $this->beanNamespace == null) { |
|
|
|||
117 | $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json'); |
||
118 | |||
119 | $autoloadNamespaces = $classNameMapper->getManagedNamespaces(); |
||
120 | if ($autoloadNamespaces) { |
||
121 | $this->autoloadDetected = true; |
||
122 | $rootNamespace = $autoloadNamespaces[0]; |
||
123 | $this->daoNamespace = $rootNamespace.'Dao'; |
||
124 | $this->beanNamespace = $rootNamespace.'Dao\\Bean'; |
||
125 | } else { |
||
126 | $this->autoloadDetected = false; |
||
127 | $this->daoNamespace = 'YourApplication\\Dao'; |
||
128 | $this->beanNamespace = 'YourApplication\\Dao\\Bean'; |
||
129 | } |
||
130 | } else { |
||
131 | $this->autoloadDetected = true; |
||
132 | } |
||
133 | $this->defaultPath = true; |
||
134 | $this->storePath = ''; |
||
135 | |||
136 | $this->castDatesToDateTime = true; |
||
137 | |||
138 | $this->content->addFile(dirname(__FILE__).'/../../../../views/installStep2.php', $this); |
||
139 | $this->template->toHtml(); |
||
140 | } |
||
141 | |||
193 |
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.