Completed
Push — master ( a70cc5...46c150 )
by Gabriel
10s
created

ProductImage   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 39.13 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 18
loc 46
rs 10
wmc 3
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A _construct() 0 4 1
A imageExists() 9 9 1
A getProcessedEans() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Stockbase\Integration\Model\ResourceModel;
4
5
/**
6
 * Class StockItem
7
 * @package Stockbase\Integration\Model\ResourceModel
8
 */
9
class ProductImage extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
10
{
11
12
    /**
13
     * @var \Magento\Framework\EntityManager\EntityManager
14
     */
15
    protected $entityManager;
16
17
    /**
18
     * Constructor.
19
     */
20
    protected function _construct()
21
    {
22
        $this->_init('stockbase_product_images', 'id');
23
    }
24
25
    /**
26
     * @param $imageName
27
     * @param $productId
28
     * @param $ean
29
     * @return mixed
30
     */
31 View Code Duplication
    public function imageExists($imageName, $productId, $ean)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        $connection = $this->getConnection();
34
        $query = $connection->select()
35
            ->from(['s' => $this->getMainTable()], ['s.ean'])
36
            ->where('s.image = ? AND s.product_id = ? AND s.ean= ?', $imageName, $productId, $ean);
37
        $eans = $connection->fetchAll($query);
38
        return $eans;
39
    }
40
41
    /**
42
     * @return mixed
43
     */
44 View Code Duplication
    public function getProcessedEans()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46
        $connection = $this->getConnection();
47
        $query = $connection->select()
48
            ->from(['s' => $this->getMainTable()], ['s.ean'])
49
            ->group('s.ean');
50
        $eans = $connection->fetchAll($query);
51
        return $eans;
52
    }
53
54
}
55