Completed
Push — master ( 9b3686...89ef78 )
by Bernhard
07:29
created

ProductMagic360ColumnsRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 40
loc 40
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 9 9 1
A findOneByProductId() 7 7 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
/**
4
 * TechDivision\Import\Product\Magic360\Repositories\ProductMagic360ColumnsRepository
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @author    Bernhard Wick <[email protected]>
16
 * @copyright 2017 TechDivision GmbH <[email protected]>
17
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
 * @link      https://github.com/techdivision/import-product-magic360
19
 * @link      http://www.techdivision.com
20
 */
21
22
namespace TechDivision\Import\Product\Magic360\Repositories;
23
24
use TechDivision\Import\Product\Magic360\Utils\MemberNames;
25
use TechDivision\Import\Repositories\AbstractRepository;
26
27
/**
28
 * Repository implementation to load magic360 column data.
29
 *
30
 * @author    Tim Wagner <[email protected]>
31
 * @author    Bernhard Wick <[email protected]>
32
 * @copyright 2017 TechDivision GmbH <[email protected]>
33
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
34
 * @link      https://github.com/techdivision/import-product-magic360
35
 * @link      http://www.techdivision.com 
36
 */
37 View Code Duplication
class ProductMagic360ColumnsRepository extends AbstractRepository
0 ignored issues
show
Duplication introduced by
This class 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
40
    /**
41
     * The prepared statement to load an existing product media gallery value entity.
42
     *
43
     * @var \PDOStatement
44
     */
45
    protected $statement;
46
47
    /**
48
     * Initializes the repository's prepared statements.
49
     *
50
     * @return void
51
     */
52
    public function init()
53
    {
54
55
        // load the utility class name
56
        $utilityClassName = $this->getUtilityClassName();
57
58
        // initialize the prepared statements
59
        $this->statement = $this->getConnection()->prepare($utilityClassName::MAGIC360_COLUMNS);
60
    }
61
62
    /**
63
     * Load's the product media gallery value with the passed value/store/parent ID.
64
     *
65
     * @param integer $productId The value ID of the product media gallery value to load
66
     *
67
     * @return array The product media gallery value
68
     */
69
    public function findOneByProductId($productId)
70
    {
71
        // load and return the prodcut media gallery value with the passed value/store/parent ID
72
        $this->statement->execute(array(MemberNames::PRODUCT_ID => $productId));
73
74
        return $this->statement->fetch(\PDO::FETCH_ASSOC);
75
    }
76
}
77