| Conditions | 2 |
| Paths | 2 |
| Total Lines | 52 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 21 | public function update(ApiCall $call, ApiKey $key, Pheal $pheal) |
||
| 22 | { |
||
| 23 | $owner = $call->getOwner(); |
||
| 24 | $charId = $owner->getCharacterId(); |
||
| 25 | |||
| 26 | $this->entityManager |
||
| 27 | ->createQuery('delete from TariochEveapiFetcherBundle:CharPlanetaryColony c where c.ownerId=:ownerId') |
||
| 28 | ->setParameter('ownerId', $charId) |
||
| 29 | ->execute(); |
||
| 30 | $this->entityManager |
||
| 31 | ->createQuery('delete from TariochEveapiFetcherBundle:CharPlanetaryPin c where c.ownerId=:ownerId') |
||
| 32 | ->setParameter('ownerId', $charId) |
||
| 33 | ->execute(); |
||
| 34 | $this->entityManager |
||
| 35 | ->createQuery('delete from TariochEveapiFetcherBundle:CharPlanetaryLink c where c.ownerId=:ownerId') |
||
| 36 | ->setParameter('ownerId', $charId) |
||
| 37 | ->execute(); |
||
| 38 | $this->entityManager |
||
| 39 | ->createQuery('delete from TariochEveapiFetcherBundle:CharPlanetaryRoute c where c.ownerId=:ownerId') |
||
| 40 | ->setParameter('ownerId', $charId) |
||
| 41 | ->execute(); |
||
| 42 | |||
| 43 | $api = $pheal->charScope->PlanetaryColonies(array( |
||
| 44 | 'characterID' => $charId |
||
| 45 | )); |
||
| 46 | |||
| 47 | foreach ($api->colonies as $colony) { |
||
| 48 | $planetId = $colony->planetID; |
||
| 49 | |||
| 50 | $this->addColony($colony, $charId); |
||
| 51 | |||
| 52 | $api = $pheal->charScope->PlanetaryPins(array( |
||
| 53 | 'characterID' => $charId, |
||
| 54 | 'planetID' => $planetId |
||
| 55 | )); |
||
| 56 | $this->addPins($api->pins, $planetId, $charId); |
||
| 57 | |||
| 58 | $api = $pheal->charScope->PlanetaryLinks(array( |
||
| 59 | 'characterID' => $charId, |
||
| 60 | 'planetID' => $planetId |
||
| 61 | )); |
||
| 62 | $this->addLinks($api->links, $planetId, $charId); |
||
| 63 | |||
| 64 | $api = $pheal->charScope->PlanetaryRoutes(array( |
||
| 65 | 'characterID' => $charId, |
||
| 66 | 'planetID' => $planetId |
||
| 67 | )); |
||
| 68 | $this->addRoutes($api->routes, $planetId, $charId); |
||
| 69 | } |
||
| 70 | |||
| 71 | return $api->cached_until; |
||
| 72 | } |
||
| 73 | |||
| 153 |