Code Duplication    Length = 35-36 lines in 2 locations

src/Repositories/EavAttributeOptionValueRepository.php 2 locations

@@ 113-147 (lines=35) @@
110
     *
111
     * @return array The EAV attribute option value
112
     */
113
    public function findOneByOptionIdAndStoreId($optionId, $storeId)
114
    {
115
116
        // the parameters of the EAV attribute option to load
117
        $params = array(
118
            MemberNames::OPTION_ID => $optionId,
119
            MemberNames::STORE_ID  => $storeId,
120
        );
121
122
        // load the utility class name
123
        $utilityClassName = $this->getUtilityClassName();
124
125
        // prepare the cache key
126
        $cacheKey = $this->cacheKey($utilityClassName::EAV_ATTRIBUTE_OPTION_VALUE_BY_OPTION_ID_AND_STORE_ID, $params);
127
128
        // return the cached result if available
129
        if ($this->isCached($cacheKey)) {
130
            return $this->fromCache($cacheKey);
131
        }
132
133
        // load and return the EAV attribute option value with the passed parameters
134
        $this->eavAttributeOptionValueByOptionIdAndStoreIdStmt->execute($params);
135
136
        // query whether or not the EAV attribute option value is available in the database
137
        if ($eavAttributeOptionValue = $this->eavAttributeOptionValueByOptionIdAndStoreIdStmt->fetch(\PDO::FETCH_ASSOC)) {
138
            // add the EAV attribute option value to the cache, register the cache key reference as well
139
            $this->toCache(
140
                $eavAttributeOptionValue[MemberNames::VALUE_ID],
141
                $eavAttributeOptionValue,
142
                array($cacheKey => $eavAttributeOptionValue[MemberNames::VALUE_ID])
143
            );
144
            // finally, return it
145
            return $eavAttributeOptionValue;
146
        }
147
    }
148
149
    /**
150
     * Load's and return's the EAV attribute option value with the passed code, store ID and value.
@@ 158-193 (lines=36) @@
155
     *
156
     * @return array The EAV attribute option value
157
     */
158
    public function findOneByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value)
159
    {
160
161
        // the parameters of the EAV attribute option to load
162
        $params = array(
163
            MemberNames::ATTRIBUTE_CODE => $attributeCode,
164
            MemberNames::STORE_ID       => $storeId,
165
            MemberNames::VALUE          => $value
166
        );
167
168
        // load the utility class name
169
        $utilityClassName = $this->getUtilityClassName();
170
171
        // prepare the cache key
172
        $cacheKey = $this->cacheKey($utilityClassName::EAV_ATTRIBUTE_OPTION_VALUE_BY_ATTRIBUTE_CODE_AND_STORE_ID_AND_VALUE, $params);
173
174
        // return the cached result if available
175
        if ($this->isCached($cacheKey)) {
176
            return $this->fromCache($cacheKey);
177
        }
178
179
        // load and return the EAV attribute option value with the passed parameters
180
        $this->eavAttributeOptionValueByAttributeCodeAndStoreIdAndValueStmt->execute($params);
181
182
        // query whether or not the result has been cached
183
        if ($eavAttributeOptionValue = $this->eavAttributeOptionValueByAttributeCodeAndStoreIdAndValueStmt->fetch(\PDO::FETCH_ASSOC)) {
184
            // add the EAV attribute option value to the cache, register the cache key reference as well
185
            $this->toCache(
186
                $eavAttributeOptionValue[MemberNames::VALUE_ID],
187
                $eavAttributeOptionValue,
188
                array($cacheKey => $eavAttributeOptionValue[MemberNames::VALUE_ID])
189
            );
190
            // finally, return it
191
            return $eavAttributeOptionValue;
192
        }
193
    }
194
}
195