| Conditions | 15 | 
| Paths | 9 | 
| Total Lines | 46 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 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 | ||
| 40 | public function set($data) | ||
| 41 |     { | ||
| 42 |         if(is_array($data) || is_object($data)) { | ||
| 43 | $mapper = \net\authorize\util\Mapper::Instance(); | ||
| 44 | 			foreach($data AS $key => $value) { | ||
| 45 | $classDetails = $mapper->getClass(get_class() , $key); | ||
| 46 | |||
| 47 | 				if($classDetails !== NULL ) { | ||
| 48 | 					if ($classDetails->isArray) { | ||
| 49 | 						if ($classDetails->isCustomDefined) { | ||
| 50 | 							foreach($value AS $keyChild => $valueChild) { | ||
| 51 | $type = new $classDetails->className; | ||
| 52 | $type->set($valueChild); | ||
| 53 | 								$this->{'addTo' . $key}($type); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | 						else if ($classDetails->className === 'DateTime' || $classDetails->className === 'Date' ) { | ||
| 57 | 							foreach($value AS $keyChild => $valueChild) { | ||
| 58 | $type = new \DateTime($valueChild); | ||
| 59 | 								$this->{'addTo' . $key}($type); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | 						else { | ||
| 63 | 							foreach($value AS $keyChild => $valueChild) { | ||
| 64 | 								$this->{'addTo' . $key}($valueChild); | ||
| 65 | } | ||
| 66 | } | ||
| 67 | } | ||
| 68 | 					else { | ||
| 69 | 						if ($classDetails->isCustomDefined){ | ||
| 70 | $type = new $classDetails->className; | ||
| 71 | $type->set($value); | ||
| 72 | 							$this->{'set' . $key}($type); | ||
| 73 | } | ||
| 74 | 						else if ($classDetails->className === 'DateTime' || $classDetails->className === 'Date' ) { | ||
| 75 | $type = new \DateTime($value); | ||
| 76 | 							$this->{'set' . $key}($type); | ||
| 77 | } | ||
| 78 | 						else { | ||
| 79 | 							$this->{'set' . $key}($value); | ||
| 80 | } | ||
| 81 | } | ||
| 82 | } | ||
| 83 | } | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 89 |