Code Duplication    Length = 19-24 lines in 2 locations

src/Observers/AttributeOptionUpdateObserver.php 1 location

@@ 45-63 (lines=19) @@
42
     *
43
     * @return array The initialized EAV attribute option
44
     */
45
    protected function initializeAttribute(array $attr)
46
    {
47
48
        // load the entity type ID for the value from the system configuration
49
        $entityTypeId = $this->getEntityTypeId();
50
51
        // initialize the data to load the EAV attribute option
52
        $value = $this->getValue(ColumnKeys::VALUE);
53
        $storeId = $this->getRowStoreId(StoreViewCodes::ADMIN);
54
        $attributeCode = $this->getValue(ColumnKeys::ATTRIBUTE_CODE);
55
56
        // try to load the EAV attribute option
57
        if ($attributeOption = $this->loadAttributeOptionByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($entityTypeId, $attributeCode, $storeId, $value)) {
58
            return $this->mergeEntity($attributeOption, $attr);
59
        }
60
61
        // simply return the attributes
62
        return $attr;
63
    }
64
65
    /**
66
     * Load's and return's the EAV attribute option with the passed entity type ID, code, store ID and value.

src/Observers/PreLoadAttributeOptionIdObserver.php 1 location

@@ 71-94 (lines=24) @@
68
     *
69
     * @return array The processed row
70
     */
71
    protected function process()
72
    {
73
74
        // load the store value and the attribute code
75
        $value = $this->getValue(ColumnKeys::ADMIN_STORE_VALUE);
76
        $attributeCode = $this->getValue(ColumnKeys::ATTRIBUTE_CODE);
77
78
        // query whether or not, we've found a new attribute code => means we've found a new EAV attribute
79
        if ($this->hasBeenProcessed($attributeCode, $value)) {
80
            return;
81
        }
82
83
        // load the entity type ID for the value from the system configuration
84
        $entityTypeId = $this->getEntityTypeId();
85
86
        // load the ID of the admin store
87
        $storeId = $this->getStoreId(StoreViewCodes::ADMIN);
88
89
        // load the EAV attribute option with the passed value
90
        $attributeOption = $this->loadAttributeOptionByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($entityTypeId, $attributeCode, $storeId, $value);
91
92
        // preserve the attribute ID for the passed EAV attribute option
93
        $this->preLoadOptionId($attributeOption);
94
    }
95
96
    /**
97
     * Queries whether or not the option with the passed code/value has already been processed.