Passed
Push — master ( bf42cc...349842 )
by Peter
05:57
created

ContactForm::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 19
rs 9.9666
cc 1
nc 1
nop 8

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Contact\Http\Controllers\Admin\Form;
6
7
use AbterPhp\Contact\Domain\Entities\Form as Entity;
8
use AbterPhp\Contact\Form\Factory\Form as FormFactory;
9
use AbterPhp\Contact\Orm\FormRepo as Repo;
10
use AbterPhp\Framework\Domain\Entities\IStringerEntity;
11
use AbterPhp\Framework\Http\Controllers\Admin\FormAbstract;
12
use AbterPhp\Framework\I18n\ITranslator;
13
use AbterPhp\Framework\Session\FlashService;
14
use Opulence\Events\Dispatchers\IEventDispatcher;
15
use Opulence\Routing\Urls\UrlGenerator;
16
use Opulence\Sessions\ISession;
17
use Psr\Log\LoggerInterface;
18
19
class ContactForm extends FormAbstract
20
{
21
    const ENTITY_SINGULAR = 'contactForm';
22
    const ENTITY_PLURAL   = 'contactForms';
23
24
    const ENTITY_TITLE_SINGULAR = 'contact:contactForm';
25
    const ENTITY_TITLE_PLURAL   = 'contact:contactForms';
26
27
    /** @var string */
28
    protected $resource = 'contactforms';
29
30
    /**
31
     * ContactForm constructor.
32
     *
33
     * @param FlashService     $flashService
34
     * @param ITranslator      $translator
35
     * @param UrlGenerator     $urlGenerator
36
     * @param LoggerInterface  $logger
37
     * @param Repo             $repo
38
     * @param ISession         $session
39
     * @param FormFactory      $formFactory
40
     * @param IEventDispatcher $eventDispatcher
41
     */
42
    public function __construct(
43
        FlashService $flashService,
44
        ITranslator $translator,
45
        UrlGenerator $urlGenerator,
46
        LoggerInterface $logger,
47
        Repo $repo,
48
        ISession $session,
49
        FormFactory $formFactory,
50
        IEventDispatcher $eventDispatcher
51
    ) {
52
        parent::__construct(
53
            $flashService,
54
            $translator,
55
            $urlGenerator,
56
            $logger,
57
            $repo,
58
            $session,
59
            $formFactory,
60
            $eventDispatcher
61
        );
62
    }
63
64
    /**
65
     * @param string $entityId
66
     *
67
     * @return Entity
68
     */
69
    protected function createEntity(string $entityId): IStringerEntity
70
    {
71
        return new Entity($entityId, '', '', '', '');
72
    }
73
}
74