Passed
Push — master ( 1888ff...f2e9e8 )
by Hector Luis
28:29
created

Base::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 15
rs 10
cc 1
nc 1
nop 9

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
declare(strict_types=1);
3
4
/**
5
 * Entity Collection Class
6
 * @package Ticaje_Circuitable
7
 * @author Hector Luis Barrientos <[email protected]>
8
 */
9
10
namespace Ticaje\Base\Persistence\Entity\Resource\Collection;
11
12
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
13
use Magento\Framework\Data\Collection\EntityFactoryInterface;
14
use Psr\Log\LoggerInterface;
15
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
16
use Magento\Framework\Event\ManagerInterface;
17
use Magento\Framework\DB\Adapter\AdapterInterface;
18
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
19
20
/**
21
 * Class Base
22
 * @package Ticaje\Base\Persistence\Entity\Resource\Collection
23
 */
24
class Base extends AbstractCollection
25
{
26
    /**
27
     * Base constructor.
28
     * @param EntityFactoryInterface $entityFactory
29
     * @param LoggerInterface $logger
30
     * @param FetchStrategyInterface $fetchStrategy
31
     * @param ManagerInterface $eventManager
32
     * @param AdapterInterface|null $connection
33
     * @param AbstractDb|null $resource
34
     * @param string $idFieldName
35
     * @param string $model
36
     * @param string $resourceModel
37
     */
38
    public function __construct(
39
        EntityFactoryInterface $entityFactory,
40
        LoggerInterface $logger,
41
        FetchStrategyInterface $fetchStrategy,
42
        ManagerInterface $eventManager,
43
        AdapterInterface $connection = null,
44
        AbstractDb $resource = null,
45
        string $idFieldName,
46
        string $model,
47
        string $resourceModel
48
    ) {
49
        $this->_idFieldName = $idFieldName;
50
        $this->_model = $model;
51
        $this->_resourceModel = $resourceModel;
52
        parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
53
    }
54
}
55