Code Duplication    Length = 24-24 lines in 2 locations

src/Subjects/AbstractEavSubject.php 2 locations

@@ 258-281 (lines=24) @@
255
     * @return array The attribute set data
256
     * @throws \Exception Is thrown, if the attribute set with the passed name is not available
257
     */
258
    public function getAttributeSetByAttributeSetName($attributeSetName)
259
    {
260
261
        // query whether or not attribute sets for the actualy entity type code are available
262
        if (isset($this->attributeSets[$entityTypeCode = $this->getEntityTypeCode()])) {
263
            // load the attribute sets for the actualy entity type code
264
            $attributSets = $this->attributeSets[$entityTypeCode];
265
266
            // query whether or not, the requested attribute set is available
267
            if (isset($attributSets[$attributeSetName])) {
268
                return $attributSets[$attributeSetName];
269
            }
270
        }
271
272
        // throw an exception, if not
273
        throw new \Exception(
274
            sprintf(
275
                'Found invalid attribute set name %s in file %s on line %d',
276
                $attributeSetName,
277
                $this->getFilename(),
278
                $this->getLineNumber()
279
            )
280
        );
281
    }
282
283
    /**
284
     * Return's the attributes for the attribute set of the product that has to be created.
@@ 289-312 (lines=24) @@
286
     * @return array The attributes
287
     * @throws \Exception Is thrown if the attributes for the actual attribute set are not available
288
     */
289
    public function getAttributes()
290
    {
291
292
        // query whether or not, the requested EAV attributes are available
293
        if (isset($this->attributes[$entityTypeCode = $this->getEntityTypeCode()])) {
294
            // load the attributes for the entity type code
295
            $attributes = $this->attributes[$entityTypeCode];
296
297
            // query whether or not attributes for the actual attribute set name
298
            if (isset($attributes[$attributeSetName = $this->attributeSet[MemberNames::ATTRIBUTE_SET_NAME]])) {
299
                return $attributes[$attributeSetName];
300
            }
301
        }
302
303
        // throw an exception, if not
304
        throw new \Exception(
305
            sprintf(
306
                'Found invalid attribute set name "%s" in file %s on line %d',
307
                $attributeSetName,
308
                $this->getFilename(),
309
                $this->getLineNumber()
310
            )
311
        );
312
    }
313
314
    /**
315
     * Return's an array with the available user defined EAV attributes for the actual entity type.