| Conditions | 13 |
| Paths | 30 |
| Total Lines | 35 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
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 |
||
| 36 | public function getForm($identifier,$instance,$modal=false){ |
||
|
|
|||
| 37 | $form=$this->jquery->semantic()->dataForm($identifier, $instance); |
||
| 38 | $className=\get_class($instance); |
||
| 39 | $form->setFields($this->controller->getAdminData()->getFormFieldNames($className)); |
||
| 40 | |||
| 41 | $fieldTypes=OrmUtils::getFieldTypes($className); |
||
| 42 | foreach ($fieldTypes as $property=>$type){ |
||
| 43 | switch ($type){ |
||
| 44 | case "boolean": |
||
| 45 | $form->fieldAsCheckbox($property); |
||
| 46 | break; |
||
| 47 | case "int": |
||
| 48 | $form->fieldAsInput($property,["inputType"=>"number"]); |
||
| 49 | break; |
||
| 50 | case "password": |
||
| 51 | $form->fieldAs($property, ["inputType"=>"password"]); |
||
| 52 | break; |
||
| 53 | case "email": |
||
| 54 | $form->fieldAsInput($property,["inputType"=>"email","rules"=>["email"]]); |
||
| 55 | break; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | $relations = OrmUtils::getFieldsInRelations($className); |
||
| 59 | foreach ($relations as $member){ |
||
| 60 | if($this->controller->getAdminData()->getUpdateManyToOneInForm() && OrmUtils::getAnnotationInfoMember($className, "#manyToOne",$member)!==false){ |
||
| 61 | $this->manyToOneFormField($form, $member, $className, $instance); |
||
| 62 | }elseif($this->controller->getAdminData()->getUpdateOneToManyInForm() && ($annot=OrmUtils::getAnnotationInfoMember($className, "#oneToMany",$member))!==false){ |
||
| 63 | $this->oneToManyFormField($form, $member, $className, $instance,$annot); |
||
| 64 | }elseif($this->controller->getAdminData()->getUpdateManyToManyInForm() && ($annot=OrmUtils::getAnnotationInfoMember($className, "#manyToMany",$member))!==false){ |
||
| 65 | $this->manyToManyFormField($form, $member, $className, $instance,$annot); |
||
| 66 | } |
||
| 67 | } |
||
| 68 | $form->setSubmitParams("Admin/update", "#table-details"); |
||
| 69 | return $form; |
||
| 70 | } |
||
| 71 | |||
| 124 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.