Passed
Push — PAC-894 ( 56c856 )
by
unknown
29:39 queued 25:27
created

SqlStatementRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 10
c 1
b 0
f 0
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
1
<?php
2
/**
3
 * Copyright (c) 2024 TechDivision GmbH <[email protected]> - TechDivision GmbH
4
 * All rights reserved
5
 *
6
 * This product includes proprietary software developed at TechDivision GmbH, Germany
7
 * For more information see https://www.techdivision.com
8
 *
9
 * To obtain a valid license for using this software, please contact us at
10
 * [email protected]
11
 */
12
declare(strict_types=1);
13
14
namespace TechDivision\Import\Product\Grouped\Repositories;
15
16
use IteratorAggregate;
17
use TechDivision\Import\Dbal\Utils\SqlCompilerInterface;
18
use TechDivision\Import\Product\Grouped\Utils\SqlStatementKeys;
19
20
/**
21
 * @copyright Copyright (c) 2024 TechDivision GmbH <[email protected]> - TechDivision GmbH
22
 * @link http://www.techdivision.com
23
 * @author MET <[email protected]>
24
 */
25
class SqlStatementRepository extends \TechDivision\Import\Product\Repositories\SqlStatementRepository
26
{
27
    /**
28
     * The SQL statements.
29
     *
30
     * @var array
31
     */
32
    private array $statements = [
33
        SqlStatementKeys::DELETE_PRODUCT_RELATION =>
34
            'DELETE
35
               FROM ${table:catalog_product_relation}
36
              WHERE parent_id = :parent_id
37
                AND child_id
38
             NOT IN (SELECT `entity_id` FROM ${table:catalog_product_entity} WHERE `sku` IN (:skus))',
39
    ];
40
41
    /**
42
     * Initializes the SQL statement repository with the primary key and table prefix utility.
43
     *
44
     * @param IteratorAggregate<SqlCompilerInterface> $compilers The array with the compiler instances
45
     */
46
    public function __construct(IteratorAggregate $compilers)
47
    {
48
        // pass primary key + table prefix utility to parent instance
49
        parent::__construct($compilers);
50
51
        // compile the SQL statements
52
        $this->compile($this->statements);
53
    }
54
}
55