Code Duplication    Length = 28-28 lines in 2 locations

src/Subjects/AbstractEavSubject.php 2 locations

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