ProductImage::getProcessedEans()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 9
Ratio 90 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 9
loc 10
ccs 0
cts 7
cp 0
crap 2
rs 9.9332
c 0
b 0
f 0
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
     * @param string $imageName
19
     * @param string $productId
20
     * @param string $ean
21
     * @return mixed
22
     */
23 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...
24
    {
25
        $connection = $this->getConnection();
26
        $query = $connection->select()
27
            ->from(['s' => $this->getMainTable()], ['s.ean'])
28
            ->where('s.image = ? AND s.product_id = ? AND s.ean= ?', $imageName, $productId, $ean);
29
        $eans = $connection->fetchAll($query);
30
        
31
        return $eans;
32
    }
33
34
    /**
35
     * @return mixed
36
     */
37 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...
38
    {
39
        $connection = $this->getConnection();
40
        $query = $connection->select()
41
            ->from(['s' => $this->getMainTable()], ['s.ean'])
42
            ->group('s.ean');
43
        $eans = $connection->fetchAll($query);
44
        
45
        return $eans;
46
    }
47
48
    /**
49
     * Constructor.
50
     */
51
    protected function _construct()
52
    {
53
        $this->_init('stockbase_product_images', 'id');
54
    }
55
}
56