Code Duplication    Length = 24-24 lines in 2 locations

src/Subjects/AbstractEavSubject.php 2 locations

@@ 220-243 (lines=24) @@
217
     * @return array The attribute set data
218
     * @throws \Exception Is thrown, if the attribute set with the passed name is not available
219
     */
220
    public function getAttributeSetByAttributeSetName($attributeSetName)
221
    {
222
223
        // query whether or not attribute sets for the actualy entity type code are available
224
        if (isset($this->attributeSets[$entityTypeCode = $this->getEntityTypeCode()])) {
225
            // load the attribute sets for the actualy entity type code
226
            $attributSets = $this->attributeSets[$entityTypeCode];
227
228
            // query whether or not, the requested attribute set is available
229
            if (isset($attributSets[$attributeSetName])) {
230
                return $attributSets[$attributeSetName];
231
            }
232
        }
233
234
        // throw an exception, if not
235
        throw new \Exception(
236
            sprintf(
237
                'Found invalid attribute set name %s in file %s on line %d',
238
                $attributeSetName,
239
                $this->getFilename(),
240
                $this->getLineNumber()
241
            )
242
        );
243
    }
244
245
    /**
246
     * Return's the attributes for the attribute set of the product that has to be created.
@@ 251-274 (lines=24) @@
248
     * @return array The attributes
249
     * @throws \Exception Is thrown if the attributes for the actual attribute set are not available
250
     */
251
    public function getAttributes()
252
    {
253
254
        // query whether or not, the requested EAV attributes are available
255
        if (isset($this->attributes[$entityTypeCode = $this->getEntityTypeCode()])) {
256
            // load the attributes for the entity type code
257
            $attributes = $this->attributes[$entityTypeCode];
258
259
            // query whether or not attributes for the actual attribute set name
260
            if (isset($attributes[$attributeSetName = $this->attributeSet[MemberNames::ATTRIBUTE_SET_NAME]])) {
261
                return $attributes[$attributeSetName];
262
            }
263
        }
264
265
        // throw an exception, if not
266
        throw new \Exception(
267
            sprintf(
268
                'Found invalid attribute set name "%s" in file %s on line %d',
269
                $attributeSetName,
270
                $this->getFilename(),
271
                $this->getLineNumber()
272
            )
273
        );
274
    }
275
276
    /**
277
     * Return's an array with the available user defined EAV attributes for the actual entity type.