Code Duplication    Length = 45-47 lines in 4 locations

src/Repositories/ProductLinkAttributeDecimalRepository.php 1 location

@@ 36-80 (lines=45) @@
33
 * @link      https://github.com/techdivision/import-product-link
34
 * @link      http://www.techdivision.com
35
 */
36
class ProductLinkAttributeDecimalRepository extends AbstractRepository implements ProductLinkAttributeDecimalRepositoryInterface
37
{
38
39
    /**
40
     * The prepared statement to load a existing product link attribute integer attribute.
41
     *
42
     * @var \PDOStatement
43
     */
44
    protected $productLinkAttributeDecimalStmt;
45
46
    /**
47
     * Initializes the repository's prepared statements.
48
     *
49
     * @return void
50
     */
51
    public function init()
52
    {
53
54
        // initialize the prepared statements
55
        $this->productLinkAttributeDecimalStmt =
56
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::PRODUCT_LINK_ATTRIBUTE_DECIMAL));
57
    }
58
59
    /**
60
     * Return's the product link attribute decimal value with the passed product link attribute/link ID.
61
     *
62
     * @param integer $productLinkAttributeId The product link attribute ID of the attributes
63
     * @param integer $linkId                 The link ID of the attribute
64
     *
65
     * @return array The product link attribute decimal value
66
     */
67
    public function findOneByProductLinkAttributeIdAndLinkId($productLinkAttributeId, $linkId)
68
    {
69
70
        // initialize the params
71
        $params = array(
72
            MemberNames::PRODUCT_LINK_ATTRIBUTE_ID => $productLinkAttributeId,
73
            MemberNames::LINK_ID                   => $linkId
74
        );
75
76
        // load and return the prodcut link attribute decimal attribute with the passed product link attribute/link ID
77
        $this->productLinkAttributeDecimalStmt->execute($params);
78
        return $this->productLinkAttributeDecimalStmt->fetch(\PDO::FETCH_ASSOC);
79
    }
80
}
81

src/Repositories/ProductLinkAttributeIntRepository.php 1 location

@@ 36-80 (lines=45) @@
33
 * @link      https://github.com/techdivision/import-product-link
34
 * @link      http://www.techdivision.com
35
 */
36
class ProductLinkAttributeIntRepository extends AbstractRepository implements ProductLinkAttributeIntRepositoryInterface
37
{
38
39
    /**
40
     * The prepared statement to load a existing product link attribute integer attribute.
41
     *
42
     * @var \PDOStatement
43
     */
44
    protected $productLinkAttributeIntStmt;
45
46
    /**
47
     * Initializes the repository's prepared statements.
48
     *
49
     * @return void
50
     */
51
    public function init()
52
    {
53
54
        // initialize the prepared statements
55
        $this->productLinkAttributeIntStmt =
56
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::PRODUCT_LINK_ATTRIBUTE_INT));
57
    }
58
59
    /**
60
     * Return's the product link attribute integer value with the passed product link attribute/link ID.
61
     *
62
     * @param integer $productLinkAttributeId The product link attribute ID of the attributes
63
     * @param integer $linkId                 The link ID of the attribute
64
     *
65
     * @return array The product link attribute integer value
66
     */
67
    public function findOneByProductLinkAttributeIdAndLinkId($productLinkAttributeId, $linkId)
68
    {
69
70
        // initialize the params
71
        $params = array(
72
            MemberNames::PRODUCT_LINK_ATTRIBUTE_ID => $productLinkAttributeId,
73
            MemberNames::LINK_ID                   => $linkId
74
        );
75
76
        // load and return the prodcut link attribute integer attribute with the passed product link attribute/link ID
77
        $this->productLinkAttributeIntStmt->execute($params);
78
        return $this->productLinkAttributeIntStmt->fetch(\PDO::FETCH_ASSOC);
79
    }
80
}
81

src/Repositories/ProductLinkAttributeVarcharRepository.php 1 location

@@ 36-80 (lines=45) @@
33
 * @link      https://github.com/techdivision/import-product-link
34
 * @link      http://www.techdivision.com
35
 */
36
class ProductLinkAttributeVarcharRepository extends AbstractRepository implements ProductLinkAttributeVarcharRepositoryInterface
37
{
38
39
    /**
40
     * The prepared statement to load a existing product link attribute varchar attribute.
41
     *
42
     * @var \PDOStatement
43
     */
44
    protected $productLinkAttributeVarcharStmt;
45
46
    /**
47
     * Initializes the repository's prepared statements.
48
     *
49
     * @return void
50
     */
51
    public function init()
52
    {
53
54
        // initialize the prepared statements
55
        $this->productLinkAttributeVarcharStmt =
56
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::PRODUCT_LINK_ATTRIBUTE_VARCHAR));
57
    }
58
59
    /**
60
     * Return's the product link attribute varchar value with the passed product link attribute/link ID.
61
     *
62
     * @param integer $productLinkAttributeId The product link attribute ID of the attributes
63
     * @param integer $linkId                 The link ID of the attribute
64
     *
65
     * @return array The product link attribute varchar value
66
     */
67
    public function findOneByProductLinkAttributeIdAndLinkId($productLinkAttributeId, $linkId)
68
    {
69
70
        // initialize the params
71
        $params = array(
72
            MemberNames::PRODUCT_LINK_ATTRIBUTE_ID => $productLinkAttributeId,
73
            MemberNames::LINK_ID                   => $linkId
74
        );
75
76
        // load and return the prodcut link attribute varchar attribute with the passed product link attribute/link ID
77
        $this->productLinkAttributeVarcharStmt->execute($params);
78
        return $this->productLinkAttributeVarcharStmt->fetch(\PDO::FETCH_ASSOC);
79
    }
80
}
81

src/Repositories/ProductLinkRepository.php 1 location

@@ 36-82 (lines=47) @@
33
 * @link      https://github.com/techdivision/import-product-link
34
 * @link      http://www.techdivision.com
35
 */
36
class ProductLinkRepository extends AbstractRepository implements ProductLinkRepositoryInterface
37
{
38
39
    /**
40
     * The prepared statement to load a existing product link.
41
     *
42
     * @var \PDOStatement
43
     */
44
    protected $linkStmt;
45
46
    /**
47
     * Initializes the repository's prepared statements.
48
     *
49
     * @return void
50
     */
51
    public function init()
52
    {
53
54
        // initialize the prepared statements
55
        $this->productLinkStmt =
56
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::PRODUCT_LINK));
57
    }
58
59
    /**
60
     * Load's the product link with the passed product/linked product/link type ID.
61
     *
62
     * @param integer $productId       The product ID of the link to load
63
     * @param integer $linkedProductId The linked product ID of the link to load
64
     * @param integer $linkTypeId      The link type ID of the product to load
65
     *
66
     * @return array The link
67
     */
68
    public function findOneByProductIdAndLinkedProductIdAndLinkTypeId($productId, $linkedProductId, $linkTypeId)
69
    {
70
71
        // initialize the params
72
        $params = array(
73
            MemberNames::PRODUCT_ID        => $productId,
74
            MemberNames::LINKED_PRODUCT_ID => $linkedProductId,
75
            MemberNames::LINK_TYPE_ID      => $linkTypeId
76
        );
77
78
        // load and return the prodcut link with the passed product/linked product/link type ID
79
        $this->productLinkStmt->execute($params);
80
        return $this->productLinkStmt->fetch(\PDO::FETCH_ASSOC);
81
    }
82
}
83