| Conditions | 23 |
| Paths | 2 |
| Total Lines | 92 |
| Code Lines | 64 |
| Lines | 0 |
| Ratio | 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 |
||
| 27 | public function setItems($items) |
||
| 28 | { |
||
| 29 | // by Warringer\Types\Base |
||
| 30 | $converters = []; |
||
| 31 | $converters['solarSystem'] = function ($value) { return $value; }; |
||
| 32 | $converters['specialization'] = function ($value) { return $value; }; |
||
| 33 | $converters['creationTime'] = function ($value) { return $value; }; |
||
| 34 | $converters['workers'] = function ($values) { |
||
| 35 | // by Warringer\Types\Dict |
||
| 36 | $converters = []; |
||
| 37 | $converters['bonus'] = function ($value) { return $value; }; |
||
| 38 | $converters['specialization'] = function ($value) { return $value; }; |
||
| 39 | |||
| 40 | $func = function ($value) use($converters) { |
||
| 41 | $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS); |
||
| 42 | $return['bonus'] = isset($value->{'bonus'}) ? $converters['bonus']($value->{'bonus'}) : null; |
||
| 43 | $return['specialization'] = isset($value->{'specialization'}) ? $converters['specialization']($value->{'specialization'}) : null; |
||
| 44 | return $return; |
||
| 45 | }; |
||
| 46 | |||
| 47 | foreach ($values as $key => $value) { |
||
| 48 | $values[$key] = $func($value); |
||
| 49 | } |
||
| 50 | return $values; |
||
| 51 | }; |
||
| 52 | |||
| 53 | $converters['expiryTime'] = function ($value) { return $value; }; |
||
| 54 | $converters['solarSystemBids'] = function ($values) { |
||
| 55 | // by Warringer\Types\Dict |
||
| 56 | $converters = []; |
||
| 57 | $converters['characterBids'] = function ($values) { |
||
| 58 | // by Warringer\Types\Dict |
||
| 59 | $converters = []; |
||
| 60 | $converters['character'] = function ($value) { return $value; }; |
||
| 61 | $converters['bidAmount'] = function ($value) { return $value; }; |
||
| 62 | |||
| 63 | $func = function ($value) use($converters) { |
||
| 64 | $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS); |
||
| 65 | $return['character'] = isset($value->{'character'}) ? $converters['character']($value->{'character'}) : null; |
||
| 66 | $return['bidAmount'] = isset($value->{'bidAmount'}) ? $converters['bidAmount']($value->{'bidAmount'}) : null; |
||
| 67 | return $return; |
||
| 68 | }; |
||
| 69 | |||
| 70 | foreach ($values as $key => $value) { |
||
| 71 | $values[$key] = $func($value); |
||
| 72 | } |
||
| 73 | return $values; |
||
| 74 | }; |
||
| 75 | |||
| 76 | $converters['solarSystem'] = function ($value) { return $value; }; |
||
| 77 | $converters['bidAmount'] = function ($value) { return $value; }; |
||
| 78 | |||
| 79 | $func = function ($value) use($converters) { |
||
| 80 | $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS); |
||
| 81 | $return['characterBids'] = isset($value->{'characterBids'}) ? $converters['characterBids']($value->{'characterBids'}) : null; |
||
| 82 | $return['solarSystem'] = isset($value->{'solarSystem'}) ? $converters['solarSystem']($value->{'solarSystem'}) : null; |
||
| 83 | $return['bidAmount'] = isset($value->{'bidAmount'}) ? $converters['bidAmount']($value->{'bidAmount'}) : null; |
||
| 84 | return $return; |
||
| 85 | }; |
||
| 86 | |||
| 87 | foreach ($values as $key => $value) { |
||
| 88 | $values[$key] = $func($value); |
||
| 89 | } |
||
| 90 | return $values; |
||
| 91 | }; |
||
| 92 | |||
| 93 | $converters['auctionExpiryTime'] = function ($value) { return $value; }; |
||
| 94 | $converters['activity'] = function ($value) { return $value; }; |
||
| 95 | $converters['costModifier'] = function ($value) { return $value; }; |
||
| 96 | $converters['id'] = function ($value) { return $value; }; |
||
| 97 | $converters['name'] = function ($value) { return $value; }; |
||
| 98 | |||
| 99 | $func = function ($value) use($converters) { |
||
| 100 | $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS); |
||
| 101 | $return['solarSystem'] = isset($value->{'solarSystem'}) ? $converters['solarSystem']($value->{'solarSystem'}) : null; |
||
| 102 | $return['specialization'] = isset($value->{'specialization'}) ? $converters['specialization']($value->{'specialization'}) : null; |
||
| 103 | $return['creationTime'] = isset($value->{'creationTime'}) ? $converters['creationTime']($value->{'creationTime'}) : null; |
||
| 104 | $return['workers'] = isset($value->{'workers'}) ? $converters['workers']($value->{'workers'}) : null; |
||
| 105 | $return['expiryTime'] = isset($value->{'expiryTime'}) ? $converters['expiryTime']($value->{'expiryTime'}) : null; |
||
| 106 | $return['solarSystemBids'] = isset($value->{'solarSystemBids'}) ? $converters['solarSystemBids']($value->{'solarSystemBids'}) : null; |
||
| 107 | $return['auctionExpiryTime'] = isset($value->{'auctionExpiryTime'}) ? $converters['auctionExpiryTime']($value->{'auctionExpiryTime'}) : null; |
||
| 108 | $return['activity'] = isset($value->{'activity'}) ? $converters['activity']($value->{'activity'}) : null; |
||
| 109 | $return['costModifier'] = isset($value->{'costModifier'}) ? $converters['costModifier']($value->{'costModifier'}) : null; |
||
| 110 | $return['id'] = isset($value->{'id'}) ? $converters['id']($value->{'id'}) : null; |
||
| 111 | $return['name'] = isset($value->{'name'}) ? $converters['name']($value->{'name'}) : null; |
||
| 112 | return $return; |
||
| 113 | }; |
||
| 114 | |||
| 115 | foreach ($items as $key => $value) { |
||
| 116 | $this->items[$key] = $func($value); |
||
| 117 | } |
||
| 118 | } |
||
| 119 | |||
| 139 |