Code Duplication    Length = 28-28 lines in 2 locations

src/Subjects/AbstractEavSubject.php 2 locations

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