Completed
Pull Request — master (#19)
by Tim
06:43
created

SqlStatementRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 64
ccs 0
cts 6
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Link\Repositories\SqlStatements
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
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-product-link
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Link\Repositories;
22
23
use TechDivision\Import\Product\Link\Utils\SqlStatementKeys;
24
25
/**
26
 * Repository class with the SQL statements to use.
27
 *
28
 * @author    Tim Wagner <[email protected]>
29
 * @copyright 2016 TechDivision GmbH <[email protected]>
30
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
31
 * @link      https://github.com/techdivision/import-product-link
32
 * @link      http://www.techdivision.com
33
 */
34
class SqlStatementRepository extends \TechDivision\Import\Product\Repositories\SqlStatementRepository
35
{
36
37
    /**
38
     * The SQL statements.
39
     *
40
     * @var array
41
     */
42
    private $statements = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
43
        SqlStatementKeys::PRODUCT_LINK =>
44
            'SELECT *
45
               FROM catalog_product_link
46
              WHERE product_id = :product_id
47
                AND linked_product_id = :linked_product_id
48
                AND link_type_id = :link_type_id',
49
        SqlStatementKeys::PRODUCT_LINK_ATTRIBUTE_INT =>
50
            'SELECT *
51
               FROM catalog_product_link_attribute_int
52
              WHERE product_link_attribute_id = :product_link_attribute_id
53
                AND link_id = :link_id',
54
        SqlStatementKeys::CREATE_PRODUCT_LINK =>
55
            'INSERT
56
               INTO catalog_product_link
57
                    (product_id,
58
                     linked_product_id,
59
                     link_type_id)
60
             VALUES (:product_id,
61
                     :linked_product_id,
62
                     :link_type_id)',
63
        SqlStatementKeys::UPDATE_PRODUCT_LINK =>
64
            'UPDATE catalog_product_link
65
                SET product_id = :product_id,
66
                    linked_product_id = :linked_product_id,
67
                    link_type_id = :link_type_id
68
              WHERE link_id = :link_id',
69
        SqlStatementKeys::CREATE_PRODUCT_LINK_ATTRIBUTE_INT =>
70
            'INSERT
71
               INTO catalog_product_link_attribute_int
72
                    (product_link_attribute_id,
73
                     link_id,
74
                     value)
75
             VALUES (:product_link_attribute_id,
76
                     :link_id,
77
                     :value)',
78
        SqlStatementKeys::UPDATE_PRODUCT_LINK_ATTRIBUTE_INT =>
79
            'UPDATE catalog_product_link_attribute_int
80
                SET product_link_attribute_id = :product_link_attribute_id,
81
                    link_id = :link_id,
82
                    value = :value
83
              WHERE value_id = :value_id'
84
    );
85
86
    /**
87
     * Initialize the the SQL statements.
88
     */
89
    public function __construct()
90
    {
91
92
        // merge the class statements
93
        foreach ($this->statements as $key => $statement) {
94
            $this->preparedStatements[$key] = $statement;
95
        }
96
    }
97
}
98