Conditions | 2 |
Paths | 1 |
Total Lines | 521 |
Lines | 125 |
Ratio | 23.99 % |
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 |
||
376 | public function getServiceConfig() |
||
377 | { |
||
378 | return array( |
||
379 | 'factories' => array( |
||
380 | 'playgroundgame_module_options' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
381 | $config = $sm->get('Configuration'); |
||
382 | |||
383 | return new Options\ModuleOptions( |
||
384 | isset($config['playgroundgame'])?$config['playgroundgame']:array() |
||
385 | ); |
||
386 | }, |
||
387 | |||
388 | 'playgroundgame_game_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
389 | $mapper = new \PlaygroundGame\Mapper\Game( |
||
390 | $sm->get('doctrine.entitymanager.orm_default'), |
||
391 | $sm->get('playgroundgame_module_options'), |
||
392 | $sm |
||
393 | ); |
||
394 | |||
395 | return $mapper; |
||
396 | }, |
||
397 | |||
398 | 'playgroundgame_playerform_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
399 | $mapper = new \PlaygroundGame\Mapper\PlayerForm( |
||
400 | $sm->get('doctrine.entitymanager.orm_default'), |
||
401 | $sm->get('playgroundgame_module_options'), |
||
402 | $sm |
||
403 | ); |
||
404 | |||
405 | return $mapper; |
||
406 | }, |
||
407 | |||
408 | 'playgroundgame_lottery_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
409 | $mapper = new \PlaygroundGame\Mapper\Lottery( |
||
410 | $sm->get('doctrine.entitymanager.orm_default'), |
||
411 | $sm->get('playgroundgame_module_options'), |
||
412 | $sm |
||
413 | ); |
||
414 | |||
415 | return $mapper; |
||
416 | }, |
||
417 | |||
418 | 'playgroundgame_instantwin_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
419 | $mapper = new \PlaygroundGame\Mapper\InstantWin( |
||
420 | $sm->get('doctrine.entitymanager.orm_default'), |
||
421 | $sm->get('playgroundgame_module_options'), |
||
422 | $sm |
||
423 | ); |
||
424 | |||
425 | return $mapper; |
||
426 | }, |
||
427 | |||
428 | 'playgroundgame_instantwinoccurrence_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
429 | $mapper = new \PlaygroundGame\Mapper\InstantWinOccurrence( |
||
430 | $sm->get('doctrine.entitymanager.orm_default'), |
||
431 | $sm->get('playgroundgame_module_options'), |
||
432 | $sm |
||
433 | ); |
||
434 | |||
435 | return $mapper; |
||
436 | }, |
||
437 | |||
438 | 'playgroundgame_quiz_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
439 | $mapper = new \PlaygroundGame\Mapper\Quiz( |
||
440 | $sm->get('doctrine.entitymanager.orm_default'), |
||
441 | $sm->get('playgroundgame_module_options'), |
||
442 | $sm |
||
443 | ); |
||
444 | |||
445 | return $mapper; |
||
446 | }, |
||
447 | |||
448 | 'playgroundgame_quizquestion_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
449 | $mapper = new \PlaygroundGame\Mapper\QuizQuestion( |
||
450 | $sm->get('doctrine.entitymanager.orm_default'), |
||
451 | $sm->get('playgroundgame_module_options'), |
||
452 | $sm |
||
453 | ); |
||
454 | |||
455 | return $mapper; |
||
456 | }, |
||
457 | |||
458 | 'playgroundgame_quizanswer_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
459 | $mapper = new \PlaygroundGame\Mapper\QuizAnswer( |
||
460 | $sm->get('doctrine.entitymanager.orm_default'), |
||
461 | $sm->get('playgroundgame_module_options'), |
||
462 | $sm |
||
463 | ); |
||
464 | |||
465 | return $mapper; |
||
466 | }, |
||
467 | |||
468 | 'playgroundgame_quizreply_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
469 | $mapper = new \PlaygroundGame\Mapper\QuizReply( |
||
470 | $sm->get('doctrine.entitymanager.orm_default'), |
||
471 | $sm->get('playgroundgame_module_options'), |
||
472 | $sm |
||
473 | ); |
||
474 | |||
475 | return $mapper; |
||
476 | }, |
||
477 | |||
478 | 'playgroundgame_quizreplyanswer_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
479 | $mapper = new \PlaygroundGame\Mapper\QuizReplyAnswer( |
||
480 | $sm->get('doctrine.entitymanager.orm_default'), |
||
481 | $sm->get('playgroundgame_module_options'), |
||
482 | $sm |
||
483 | ); |
||
484 | |||
485 | return $mapper; |
||
486 | }, |
||
487 | |||
488 | 'playgroundgame_entry_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
489 | $mapper = new \PlaygroundGame\Mapper\Entry( |
||
490 | $sm->get('doctrine.entitymanager.orm_default'), |
||
491 | $sm->get('playgroundgame_module_options'), |
||
492 | $sm |
||
493 | ); |
||
494 | |||
495 | return $mapper; |
||
496 | }, |
||
497 | |||
498 | 'playgroundgame_postvote_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
499 | $mapper = new \PlaygroundGame\Mapper\PostVote( |
||
500 | $sm->get('doctrine.entitymanager.orm_default'), |
||
501 | $sm->get('playgroundgame_module_options'), |
||
502 | $sm |
||
503 | ); |
||
504 | |||
505 | return $mapper; |
||
506 | }, |
||
507 | |||
508 | 'playgroundgame_postvoteform_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
509 | $mapper = new \PlaygroundGame\Mapper\PostVoteForm( |
||
510 | $sm->get('doctrine.entitymanager.orm_default'), |
||
511 | $sm->get('playgroundgame_module_options'), |
||
512 | $sm |
||
513 | ); |
||
514 | |||
515 | return $mapper; |
||
516 | }, |
||
517 | |||
518 | 'playgroundgame_postvotepost_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
519 | $mapper = new \PlaygroundGame\Mapper\PostVotePost( |
||
520 | $sm->get('doctrine.entitymanager.orm_default'), |
||
521 | $sm->get('playgroundgame_module_options'), |
||
522 | $sm |
||
523 | ); |
||
524 | |||
525 | return $mapper; |
||
526 | }, |
||
527 | |||
528 | 'playgroundgame_postvotepostelement_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
529 | $mapper = new \PlaygroundGame\Mapper\PostVotePostElement( |
||
530 | $sm->get('doctrine.entitymanager.orm_default'), |
||
531 | $sm->get('playgroundgame_module_options'), |
||
532 | $sm |
||
533 | ); |
||
534 | |||
535 | return $mapper; |
||
536 | }, |
||
537 | |||
538 | 'playgroundgame_postvotevote_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
539 | $mapper = new \PlaygroundGame\Mapper\PostVoteVote( |
||
540 | $sm->get('doctrine.entitymanager.orm_default'), |
||
541 | $sm->get('playgroundgame_module_options'), |
||
542 | $sm |
||
543 | ); |
||
544 | |||
545 | return $mapper; |
||
546 | }, |
||
547 | |||
548 | 'playgroundgame_postvotecomment_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
549 | $mapper = new \PlaygroundGame\Mapper\PostVoteComment( |
||
550 | $sm->get('doctrine.entitymanager.orm_default'), |
||
551 | $sm->get('playgroundgame_module_options'), |
||
552 | $sm |
||
553 | ); |
||
554 | |||
555 | return $mapper; |
||
556 | }, |
||
557 | |||
558 | 'playgroundgame_postvoteshare_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
559 | $mapper = new \PlaygroundGame\Mapper\PostVoteShare( |
||
560 | $sm->get('doctrine.entitymanager.orm_default'), |
||
561 | $sm->get('playgroundgame_module_options'), |
||
562 | $sm |
||
563 | ); |
||
564 | |||
565 | return $mapper; |
||
566 | }, |
||
567 | |||
568 | 'playgroundgame_postvoteview_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
569 | $mapper = new \PlaygroundGame\Mapper\PostVoteView( |
||
570 | $sm->get('doctrine.entitymanager.orm_default'), |
||
571 | $sm->get('playgroundgame_module_options'), |
||
572 | $sm |
||
573 | ); |
||
574 | |||
575 | return $mapper; |
||
576 | }, |
||
577 | |||
578 | 'playgroundgame_prize_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
579 | $mapper = new \PlaygroundGame\Mapper\Prize( |
||
580 | $sm->get('doctrine.entitymanager.orm_default'), |
||
581 | $sm->get('playgroundgame_module_options'), |
||
582 | $sm |
||
583 | ); |
||
584 | |||
585 | return $mapper; |
||
586 | }, |
||
587 | |||
588 | 'playgroundgame_prizecategory_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
589 | $mapper = new \PlaygroundGame\Mapper\PrizeCategory( |
||
590 | $sm->get('doctrine.entitymanager.orm_default'), |
||
591 | $sm->get('playgroundgame_module_options'), |
||
592 | $sm |
||
593 | ); |
||
594 | |||
595 | return $mapper; |
||
596 | }, |
||
597 | |||
598 | 'playgroundgame_prizecategoryuser_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
599 | $mapper = new \PlaygroundGame\Mapper\PrizeCategoryUser( |
||
600 | $sm->get('doctrine.entitymanager.orm_default'), |
||
601 | $sm->get('playgroundgame_module_options'), |
||
602 | $sm |
||
603 | ); |
||
604 | |||
605 | return $mapper; |
||
606 | }, |
||
607 | |||
608 | 'playgroundgame_invitation_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
609 | $mapper = new \PlaygroundGame\Mapper\Invitation( |
||
610 | $sm->get('doctrine.entitymanager.orm_default'), |
||
611 | $sm->get('playgroundgame_module_options'), |
||
612 | $sm |
||
613 | ); |
||
614 | |||
615 | return $mapper; |
||
616 | }, |
||
617 | |||
618 | 'playgroundgame_mission_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
619 | $mapper = new Mapper\Mission( |
||
620 | $sm->get('doctrine.entitymanager.orm_default'), |
||
621 | $sm->get('playgroundgame_module_options'), |
||
622 | $sm |
||
623 | ); |
||
624 | |||
625 | return $mapper; |
||
626 | }, |
||
627 | |||
628 | 'playgroundgame_mission_game_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
629 | $mapper = new Mapper\MissionGame( |
||
630 | $sm->get('doctrine.entitymanager.orm_default'), |
||
631 | $sm->get('playgroundgame_module_options'), |
||
632 | $sm |
||
633 | ); |
||
634 | |||
635 | return $mapper; |
||
636 | }, |
||
637 | |||
638 | 'playgroundgame_mission_game_condition_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
639 | $mapper = new Mapper\MissionGameCondition( |
||
640 | $sm->get('doctrine.entitymanager.orm_default'), |
||
641 | $sm->get('playgroundgame_module_options'), |
||
642 | $sm |
||
643 | ); |
||
644 | |||
645 | return $mapper; |
||
646 | }, |
||
647 | |||
648 | 'playgroundgame_tradingcard_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
649 | $mapper = new Mapper\TradingCard( |
||
650 | $sm->get('doctrine.entitymanager.orm_default'), |
||
651 | $sm->get('playgroundgame_module_options'), |
||
652 | $sm |
||
653 | ); |
||
654 | |||
655 | return $mapper; |
||
656 | }, |
||
657 | |||
658 | 'playgroundgame_tradingcard_model_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
659 | $mapper = new Mapper\TradingCardModel( |
||
660 | $sm->get('doctrine.entitymanager.orm_default'), |
||
661 | $sm->get('playgroundgame_module_options'), |
||
662 | $sm |
||
663 | ); |
||
664 | |||
665 | return $mapper; |
||
666 | }, |
||
667 | |||
668 | 'playgroundgame_tradingcard_card_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
669 | $mapper = new Mapper\TradingCardCard( |
||
670 | $sm->get('doctrine.entitymanager.orm_default'), |
||
671 | $sm->get('playgroundgame_module_options'), |
||
672 | $sm |
||
673 | ); |
||
674 | |||
675 | return $mapper; |
||
676 | }, |
||
677 | |||
678 | 'playgroundgame_memory_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
679 | $mapper = new Mapper\Memory( |
||
680 | $sm->get('doctrine.entitymanager.orm_default'), |
||
681 | $sm->get('playgroundgame_module_options'), |
||
682 | $sm |
||
683 | ); |
||
684 | |||
685 | return $mapper; |
||
686 | }, |
||
687 | |||
688 | 'playgroundgame_memory_card_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
689 | $mapper = new Mapper\MemoryCard( |
||
690 | $sm->get('doctrine.entitymanager.orm_default'), |
||
691 | $sm->get('playgroundgame_module_options'), |
||
692 | $sm |
||
693 | ); |
||
694 | |||
695 | return $mapper; |
||
696 | }, |
||
697 | |||
698 | 'playgroundgame_memory_score_mapper' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
699 | $mapper = new Mapper\MemoryScore( |
||
700 | $sm->get('doctrine.entitymanager.orm_default'), |
||
701 | $sm->get('playgroundgame_module_options'), |
||
702 | $sm |
||
703 | ); |
||
704 | |||
705 | return $mapper; |
||
706 | }, |
||
707 | |||
708 | View Code Duplication | 'playgroundgame_tradingcardmodel_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
709 | $translator = $sm->get('MvcTranslator'); |
||
710 | $form = new Form\Admin\TradingCardModel(null, $sm, $translator); |
||
711 | $tradingcardmodel = new Entity\TradingCardModel(); |
||
712 | $form->setInputFilter($tradingcardmodel->getInputFilter()); |
||
713 | |||
714 | return $form; |
||
715 | }, |
||
716 | |||
717 | View Code Duplication | 'playgroundgame_tradingcard_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
718 | $translator = $sm->get('MvcTranslator'); |
||
719 | $form = new Form\Admin\TradingCard(null, $sm, $translator); |
||
720 | $tradingcard = new Entity\TradingCard(); |
||
721 | $form->setInputFilter($tradingcard->getInputFilter()); |
||
722 | |||
723 | return $form; |
||
724 | }, |
||
725 | |||
726 | View Code Duplication | 'playgroundgame_memory_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
727 | $translator = $sm->get('MvcTranslator'); |
||
728 | $form = new Form\Admin\Memory(null, $sm, $translator); |
||
729 | $memory = new Entity\Memory(); |
||
730 | $form->setInputFilter($memory->getInputFilter()); |
||
731 | |||
732 | return $form; |
||
733 | }, |
||
734 | |||
735 | View Code Duplication | 'playgroundgame_memorycard_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
736 | $translator = $sm->get('MvcTranslator'); |
||
737 | $form = new Form\Admin\MemoryCard(null, $sm, $translator); |
||
738 | $memoryCard = new Entity\MemoryCard(); |
||
739 | $form->setInputFilter($memoryCard->getInputFilter()); |
||
740 | |||
741 | return $form; |
||
742 | }, |
||
743 | |||
744 | View Code Duplication | 'playgroundgame_mission_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
745 | $translator = $sm->get('MvcTranslator'); |
||
746 | $form = new Form\Admin\Mission(null, $sm, $translator); |
||
747 | $mission = new Entity\Mission(); |
||
748 | $form->setInputFilter($mission->getInputFilter()); |
||
749 | |||
750 | return $form; |
||
751 | }, |
||
752 | |||
753 | View Code Duplication | 'playgroundgame_mission_game_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
754 | $translator = $sm->get('MvcTranslator'); |
||
755 | $form = new Form\Admin\MissionGameFieldset(null, $sm, $translator); |
||
756 | $missionGame = new Entity\MissionGame(); |
||
757 | $form->setInputFilter($missionGame->getInputFilter()); |
||
758 | return $form; |
||
759 | }, |
||
760 | |||
761 | View Code Duplication | 'playgroundgame_game_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
762 | $translator = $sm->get('MvcTranslator'); |
||
763 | $form = new Form\Admin\Game(null, $sm, $translator); |
||
764 | $game = new Entity\Game(); |
||
765 | $form->setInputFilter($game->getInputFilter()); |
||
766 | |||
767 | return $form; |
||
768 | }, |
||
769 | |||
770 | 'playgroundgame_register_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
771 | $translator = $sm->get('MvcTranslator'); |
||
772 | $zfcUserOptions = $sm->get('zfcuser_module_options'); |
||
773 | $form = new Form\Frontend\Register(null, $zfcUserOptions, $translator, $sm); |
||
774 | $form->setInputFilter(new \ZfcUser\Form\RegisterFilter( |
||
775 | new \ZfcUser\Validator\NoRecordExists(array( |
||
776 | 'mapper' => $sm->get('zfcuser_user_mapper'), |
||
777 | 'key' => 'email', |
||
778 | )), |
||
779 | new \ZfcUser\Validator\NoRecordExists(array( |
||
780 | 'mapper' => $sm->get('zfcuser_user_mapper'), |
||
781 | 'key' => 'username', |
||
782 | )), |
||
783 | $zfcUserOptions |
||
784 | )); |
||
785 | |||
786 | return $form; |
||
787 | }, |
||
788 | |||
789 | 'playgroundgame_import_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
790 | $translator = $sm->get('MvcTranslator'); |
||
791 | $form = new Form\Admin\Import(null, $sm, $translator); |
||
792 | |||
793 | return $form; |
||
794 | }, |
||
795 | |||
796 | View Code Duplication | 'playgroundgame_lottery_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
797 | $translator = $sm->get('MvcTranslator'); |
||
798 | $form = new Form\Admin\Lottery(null, $sm, $translator); |
||
799 | $lottery = new Entity\Lottery(); |
||
800 | $form->setInputFilter($lottery->getInputFilter()); |
||
801 | |||
802 | return $form; |
||
803 | }, |
||
804 | |||
805 | View Code Duplication | 'playgroundgame_quiz_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
806 | $translator = $sm->get('MvcTranslator'); |
||
807 | $form = new Form\Admin\Quiz(null, $sm, $translator); |
||
808 | $quiz = new Entity\Quiz(); |
||
809 | $form->setInputFilter($quiz->getInputFilter()); |
||
810 | |||
811 | return $form; |
||
812 | }, |
||
813 | |||
814 | View Code Duplication | 'playgroundgame_instantwin_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
815 | $translator = $sm->get('MvcTranslator'); |
||
816 | $form = new Form\Admin\InstantWin(null, $sm, $translator); |
||
817 | $instantwin = new Entity\InstantWin(); |
||
818 | $form->setInputFilter($instantwin->getInputFilter()); |
||
819 | |||
820 | return $form; |
||
821 | }, |
||
822 | |||
823 | View Code Duplication | 'playgroundgame_quizquestion_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
824 | $translator = $sm->get('MvcTranslator'); |
||
825 | $form = new Form\Admin\QuizQuestion(null, $sm, $translator); |
||
826 | $quizQuestion = new Entity\QuizQuestion(); |
||
827 | $form->setInputFilter($quizQuestion->getInputFilter()); |
||
828 | |||
829 | return $form; |
||
830 | }, |
||
831 | |||
832 | View Code Duplication | 'playgroundgame_instantwinoccurrence_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
833 | $translator = $sm->get('MvcTranslator'); |
||
834 | $form = new Form\Admin\InstantWinOccurrence(null, $sm, $translator); |
||
835 | $instantwinOccurrence = new Entity\InstantWinOccurrence(); |
||
836 | $form->setInputFilter($instantwinOccurrence->getInputFilter()); |
||
837 | |||
838 | return $form; |
||
839 | }, |
||
840 | |||
841 | 'playgroundgame_instantwinoccurrenceimport_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
842 | $translator = $sm->get('MvcTranslator'); |
||
843 | $form = new Form\Admin\InstantWinOccurrenceImport(null, $sm, $translator); |
||
844 | return $form; |
||
845 | }, |
||
846 | |||
847 | View Code Duplication | 'playgroundgame_instantwinoccurrencecode_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
848 | $translator = $sm->get('MvcTranslator'); |
||
849 | $form = new Form\Frontend\InstantWinOccurrenceCode(null, $sm, $translator); |
||
850 | $filter = new Form\Frontend\InstantWinOccurrenceCodeFilter(); |
||
851 | $form->setInputFilter($filter); |
||
852 | return $form; |
||
853 | }, |
||
854 | |||
855 | View Code Duplication | 'playgroundgame_postvote_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
856 | $translator = $sm->get('MvcTranslator'); |
||
857 | $form = new Form\Admin\PostVote(null, $sm, $translator); |
||
858 | $postVote = new Entity\PostVote(); |
||
859 | $form->setInputFilter($postVote->getInputFilter()); |
||
860 | |||
861 | return $form; |
||
862 | }, |
||
863 | |||
864 | View Code Duplication | 'playgroundgame_prizecategory_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
865 | $translator = $sm->get('MvcTranslator'); |
||
866 | $form = new Form\Admin\PrizeCategory(null, $sm, $translator); |
||
867 | $prizeCategory = new Entity\PrizeCategory(); |
||
868 | $form->setInputFilter($prizeCategory->getInputFilter()); |
||
869 | |||
870 | return $form; |
||
871 | }, |
||
872 | |||
873 | 'playgroundgame_prizecategoryuser_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
874 | $translator = $sm->get('MvcTranslator'); |
||
875 | $form = new Form\Frontend\PrizeCategoryUser(null, $sm, $translator); |
||
876 | |||
877 | return $form; |
||
878 | }, |
||
879 | |||
880 | View Code Duplication | 'playgroundgame_sharemail_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
|
881 | $translator = $sm->get('MvcTranslator'); |
||
882 | $form = new Form\Frontend\ShareMail(null, $sm, $translator); |
||
883 | $form->setInputFilter(new Form\Frontend\ShareMailFilter()); |
||
884 | |||
885 | return $form; |
||
886 | }, |
||
887 | |||
888 | 'playgroundgame_createteam_form' => function (\Zend\ServiceManager\ServiceManager $sm) { |
||
889 | $translator = $sm->get('MvcTranslator'); |
||
890 | $form = new Form\Frontend\CreateTeam(null, $sm, $translator); |
||
891 | |||
892 | return $form; |
||
893 | }, |
||
894 | ), |
||
895 | ); |
||
896 | } |
||
897 | } |
||
898 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: