Code Duplication    Length = 49-51 lines in 4 locations

src/Repositories/AttributeOptionRepository.php 1 location

@@ 35-83 (lines=49) @@
32
 * @link      https://github.com/techdivision/import-attribute
33
 * @link      http://www.techdivision.com
34
 */
35
class AttributeOptionRepository extends AbstractRepository
36
{
37
38
    /**
39
     * The prepared statement to load an existing EAV attribute option by its attribute code, store ID and value.
40
     *
41
     * @var \PDOStatement
42
     */
43
    protected $attributeOptionByAttributeCodeAndStoreIdAndValueStmt;
44
45
    /**
46
     * Initializes the repository's prepared statements.
47
     *
48
     * @return void
49
     */
50
    public function init()
51
    {
52
53
        // load the utility class name
54
        $utilityClassName = $this->getUtilityClassName();
55
56
        // initialize the prepared statements
57
        $this->attributeOptionByAttributeCodeAndStoreIdAndValueStmt = $this->getConnection()->prepare($utilityClassName::ATTRIBUTE_OPTION_BY_ATTRIBUTE_CODE_AND_STORE_ID_AND_VALUE);
58
    }
59
60
    /**
61
     * Load's and return's the EAV attribute option with the passed code, store ID and value.
62
     *
63
     * @param string  $attributeCode The code of the EAV attribute option to load
64
     * @param integer $storeId       The store ID of the attribute option to load
65
     * @param string  $value         The value of the attribute option to load
66
     *
67
     * @return array The EAV attribute option
68
     */
69
    public function findOneByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value)
70
    {
71
72
        // the parameters of the EAV attribute option to load
73
        $params = array(
74
            MemberNames::ATTRIBUTE_CODE => $attributeCode,
75
            MemberNames::STORE_ID       => $storeId,
76
            MemberNames::VALUE          => $value
77
        );
78
79
        // load and return the EAV attribute option with the passed parameters
80
        $this->attributeOptionByAttributeCodeAndStoreIdAndValueStmt->execute($params);
81
        return $this->attributeOptionByAttributeCodeAndStoreIdAndValueStmt->fetch(\PDO::FETCH_ASSOC);
82
    }
83
}
84

src/Repositories/AttributeOptionSwatchRepository.php 1 location

@@ 35-85 (lines=51) @@
32
 * @link      https://github.com/techdivision/import-attribute
33
 * @link      http://www.techdivision.com
34
 */
35
class AttributeOptionSwatchRepository extends AbstractRepository
36
{
37
38
    /**
39
     * The prepared statement to load an existing EAV attribute option swatch by its attribute code, store ID. value and type.
40
     *
41
     * @var \PDOStatement
42
     */
43
    protected $attributeOptionSwatchByAttributeCodeAndStoreIdAndValueAndTypeStmt;
44
45
    /**
46
     * Initializes the repository's prepared statements.
47
     *
48
     * @return void
49
     */
50
    public function init()
51
    {
52
53
        // load the utility class name
54
        $utilityClassName = $this->getUtilityClassName();
55
56
        // initialize the prepared statements
57
        $this->attributeOptionSwatchByAttributeCodeAndStoreIdAndValueAndTypeStmt = $this->getConnection()->prepare($utilityClassName::ATTRIBUTE_OPTION_SWATCH_BY_ATTRIBUTE_CODE_AND_STORE_ID_AND_VALUE_AND_TYPE);
58
    }
59
60
    /**
61
     * Load's and return's the EAV attribute option swatch with the passed code, store ID, value and type.
62
     *
63
     * @param string  $attributeCode The code of the EAV attribute option swatch to load
64
     * @param integer $storeId       The store ID of the attribute option swatch to load
65
     * @param string  $value         The value of the attribute option swatch to load
66
     * @param string  $type          The type of the attribute option swatch to load
67
     *
68
     * @return array The EAV attribute option swatch
69
     */
70
    public function findOneByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value, $type)
71
    {
72
73
        // the parameters of the EAV attribute option to load
74
        $params = array(
75
            MemberNames::ATTRIBUTE_CODE => $attributeCode,
76
            MemberNames::STORE_ID       => $storeId,
77
            MemberNames::VALUE          => $value,
78
            MemberNames::TYPE           => $type
79
        );
80
81
        // load and return the EAV attribute option swatch with the passed parameters
82
        $this->attributeOptionSwatchByAttributeCodeAndStoreIdAndValueAndTypeStmt->execute($params);
83
        return $this->attributeOptionSwatchByAttributeCodeAndStoreIdAndValueAndTypeStmt->fetch(\PDO::FETCH_ASSOC);
84
    }
85
}
86

src/Repositories/AttributeOptionValueRepository.php 1 location

@@ 35-83 (lines=49) @@
32
 * @link      https://github.com/techdivision/import-attribute
33
 * @link      http://www.techdivision.com
34
 */
35
class AttributeOptionValueRepository extends AbstractRepository
36
{
37
38
    /**
39
     * The prepared statement to load an existing EAV attribute option value by its attribute code, store ID and value.
40
     *
41
     * @var \PDOStatement
42
     */
43
    protected $attributeOptionValueByAttributeCodeAndStoreIdAndValueStmt;
44
45
    /**
46
     * Initializes the repository's prepared statements.
47
     *
48
     * @return void
49
     */
50
    public function init()
51
    {
52
53
        // load the utility class name
54
        $utilityClassName = $this->getUtilityClassName();
55
56
        // initialize the prepared statements
57
        $this->attributeOptionValueByAttributeCodeAndStoreIdAndValueStmt= $this->getConnection()->prepare($utilityClassName::ATTRIBUTE_OPTION_VALUE_BY_ATTRIBUTE_CODE_AND_STORE_ID_AND_VALUE);
58
    }
59
60
    /**
61
     * Load's and return's the EAV attribute option value with the passed code, store ID and value.
62
     *
63
     * @param string  $attributeCode The code of the EAV attribute option to load
64
     * @param integer $storeId       The store ID of the attribute option to load
65
     * @param string  $value         The value of the attribute option to load
66
     *
67
     * @return array The EAV attribute option value
68
     */
69
    public function findOneByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value)
70
    {
71
72
        // the parameters of the EAV attribute option to load
73
        $params = array(
74
            MemberNames::ATTRIBUTE_CODE => $attributeCode,
75
            MemberNames::STORE_ID       => $storeId,
76
            MemberNames::VALUE          => $value
77
        );
78
79
        // load and return the EAV attribute option value with the passed parameters
80
        $this->attributeOptionValueByAttributeCodeAndStoreIdAndValueStmt->execute($params);
81
        return $this->attributeOptionValueByAttributeCodeAndStoreIdAndValueStmt->fetch(\PDO::FETCH_ASSOC);
82
    }
83
}
84

src/Repositories/EntityAttributeRepository.php 1 location

@@ 35-85 (lines=51) @@
32
 * @link      https://github.com/techdivision/import-attribute
33
 * @link      http://www.techdivision.com
34
 */
35
class EntityAttributeRepository extends AbstractRepository
36
{
37
38
    /**
39
     * The prepared statement to load an existing EAV entity attribute by its attribute, attribut set and attribute group ID.
40
     *
41
     * @var \PDOStatement
42
     */
43
    protected $entityAttributeByAttributeIdAndAttributeSetIdAndAttributeGroupIdStmt;
44
45
    /**
46
     * Initializes the repository's prepared statements.
47
     *
48
     * @return void
49
     */
50
    public function init()
51
    {
52
53
        // load the utility class name
54
        $utilityClassName = $this->getUtilityClassName();
55
56
        // initialize the prepared statements
57
        $this->entityAttributeByAttributeIdAndAttributeSetIdAndAttributeGroupIdStmt = $this->getConnection()->prepare($utilityClassName::ENTITY_ATTRIBUTE_BY_ATTRIBUTE_ID_AND_ATTRIBUTE_SET_ID_AND_ATTRIBUTE_GROUP_ID);
58
    }
59
60
    /**
61
     * Return's the EAV entity attribute with the passed entity type, attribute, attribute set and attribute group ID.
62
     *
63
     * @param integer $entityTypeId     The ID of the EAV entity attribute's entity type to return
64
     * @param integer $attributeId      The ID of the EAV entity attribute's attribute to return
65
     * @param integer $attributeSetId   The ID of the EAV entity attribute's attribute set to return
66
     * @param integer $attributeGroupId The ID of the EAV entity attribute's attribute group to return
67
     *
68
     * @return array The EAV entity attribute
69
     */
70
    public function findOneByEntityTypeAndAttributeIdAndAttributeSetIdAndAttributeGroupId($entityTypeId, $attributeId, $attributeSetId, $attributeGroupId)
71
    {
72
73
        // initialize the params
74
        $params = array(
75
            MemberNames::ENTITY_TYPE_ID     => $entityTypeId,
76
            MemberNames::ATTRIBUTE_ID       => $attributeId,
77
            MemberNames::ATTRIBUTE_SET_ID   => $attributeSetId,
78
            MemberNames::ATTRIBUTE_GROUP_ID => $attributeGroupId
79
        );
80
81
        // load and return the EAV entity attribute with the passed params
82
        $this->entityAttributeByAttributeIdAndAttributeSetIdAndAttributeGroupIdStmt->execute($params);
83
        return $this->entityAttributeByAttributeIdAndAttributeSetIdAndAttributeGroupIdStmt->fetch(\PDO::FETCH_ASSOC);
84
    }
85
}
86