Code Duplication    Length = 24-24 lines in 2 locations

src/Subjects/AbstractSubject.php 2 locations

@@ 949-972 (lines=24) @@
946
     * @return array The attribute set data
947
     * @throws \Exception Is thrown, if the attribute set with the passed name is not available
948
     */
949
    public function getAttributeSetByAttributeSetName($attributeSetName)
950
    {
951
952
        // query whether or not attribute sets for the actualy entity type code are available
953
        if (isset($this->attributeSets[$entityTypeCode = $this->getEntityTypeCode()])) {
954
            // load the attribute sets for the actualy entity type code
955
            $attributSets = $this->attributeSets[$entityTypeCode];
956
957
            // query whether or not, the requested attribute set is available
958
            if (isset($attributSets[$attributeSetName])) {
959
                return $attributSets[$attributeSetName];
960
            }
961
        }
962
963
        // throw an exception, if not
964
        throw new \Exception(
965
            sprintf(
966
                'Found invalid attribute set name %s in file %s on line %d',
967
                $attributeSetName,
968
                $this->getFilename(),
969
                $this->getLineNumber()
970
            )
971
        );
972
    }
973
974
    /**
975
     * Return's the attributes for the attribute set of the product that has to be created.
@@ 980-1003 (lines=24) @@
977
     * @return array The attributes
978
     * @throws \Exception Is thrown if the attributes for the actual attribute set are not available
979
     */
980
    public function getAttributes()
981
    {
982
983
        // query whether or not, the requested EAV attributes are available
984
        if (isset($this->attributes[$entityTypeCode = $this->getEntityTypeCode()])) {
985
            // load the attributes for the entity type code
986
            $attributes = $this->attributes[$entityTypeCode];
987
988
            // query whether or not attributes for the actual attribute set name
989
            if (isset($attributes[$attributeSetName = $this->attributeSet[MemberNames::ATTRIBUTE_SET_NAME]])) {
990
                return $attributes[$attributeSetName];
991
            }
992
        }
993
994
        // throw an exception, if not
995
        throw new \Exception(
996
            sprintf(
997
                'Found invalid attribute set name "%s" in file %s on line %d',
998
                $attributeSetName,
999
                $this->getFilename(),
1000
                $this->getLineNumber()
1001
            )
1002
        );
1003
    }
1004
1005
    /**
1006
     * Return's the EAV attribute with the passed attribute code.