| Conditions | 4 |
| Paths | 5 |
| Total Lines | 55 |
| Code Lines | 35 |
| 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 |
||
| 31 | public function indexAction() |
||
| 32 | { |
||
| 33 | $identifier = $this->getEvent()->getRouteMatch()->getParam('id'); |
||
| 34 | |||
| 35 | if (!$identifier) { |
||
| 36 | return $this->notFoundAction(); |
||
| 37 | } |
||
| 38 | |||
| 39 | $prizeCategory = $this->getPrizeCategoryService()->getPrizeCategoryMapper()->findByIdentifier($identifier); |
||
| 40 | $idPrizeCategory = $prizeCategory->getId(); |
||
| 41 | |||
| 42 | $games = $this->getGameService()->getPrizeCategoryGames($idPrizeCategory); |
||
| 43 | |||
| 44 | if (!$games) { |
||
| 45 | $this->flashMessenger()->addMessage('Il n\'y a aucun jeu disponible pour cette thématique'); |
||
| 46 | } |
||
| 47 | |||
| 48 | if (is_array($games)) { |
||
| 49 | $paginator = new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\ArrayAdapter($games)); |
||
| 50 | $paginator->setItemCountPerPage(7); |
||
| 51 | $paginator->setCurrentPageNumber($this->getEvent()->getRouteMatch()->getParam('p')); |
||
| 52 | } else { |
||
| 53 | $paginator = $games; |
||
| 54 | } |
||
| 55 | |||
| 56 | $bitlyclient = $this->getOptions()->getBitlyUrl(); |
||
| 57 | $bitlyuser = $this->getOptions()->getBitlyUsername(); |
||
| 58 | $bitlykey = $this->getOptions()->getBitlyApiKey(); |
||
| 59 | |||
| 60 | $this->getViewHelper('HeadMeta')->setProperty('bt:client', $bitlyclient); |
||
| 61 | $this->getViewHelper('HeadMeta')->setProperty('bt:user', $bitlyuser); |
||
| 62 | $this->getViewHelper('HeadMeta')->setProperty('bt:key', $bitlykey); |
||
| 63 | |||
| 64 | $this->layout()->setVariables( |
||
| 65 | array( |
||
| 66 | 'breadcrumbTitle' => $prizeCategory->getTitle(), |
||
| 67 | 'currentPage' => array( |
||
| 68 | 'pageGames' => 'games', |
||
| 69 | 'pageWinners' => '' |
||
| 70 | ), |
||
| 71 | 'headParams' => array( |
||
| 72 | 'headTitle' => $prizeCategory->getTitle(), |
||
| 73 | ), |
||
| 74 | ) |
||
| 75 | ); |
||
| 76 | |||
| 77 | return new ViewModel( |
||
| 78 | array( |
||
| 79 | 'games' => $paginator, |
||
| 80 | 'prizeCategory' => $prizeCategory, |
||
| 81 | 'identifier' => $identifier, |
||
| 82 | 'flashMessages' => $this->flashMessenger()->getMessages(), |
||
| 83 | ) |
||
| 84 | ); |
||
| 85 | } |
||
| 86 | |||
| 112 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..