Code Duplication    Length = 24-24 lines in 2 locations

src/Subjects/AbstractSubject.php 2 locations

@@ 926-949 (lines=24) @@
923
     * @return array The attribute set data
924
     * @throws \Exception Is thrown, if the attribute set with the passed name is not available
925
     */
926
    public function getAttributeSetByAttributeSetName($attributeSetName)
927
    {
928
929
        // query whether or not attribute sets for the actualy entity type code are available
930
        if (isset($this->attributeSets[$entityTypeCode = $this->getEntityTypeCode()])) {
931
            // load the attribute sets for the actualy entity type code
932
            $attributSets = $this->attributeSets[$entityTypeCode];
933
934
            // query whether or not, the requested attribute set is available
935
            if (isset($attributSets[$attributeSetName])) {
936
                return $attributSets[$attributeSetName];
937
            }
938
        }
939
940
        // throw an exception, if not
941
        throw new \Exception(
942
            sprintf(
943
                'Found invalid attribute set name %s in file %s on line %d',
944
                $attributeSetName,
945
                $this->getFilename(),
946
                $this->getLineNumber()
947
            )
948
        );
949
    }
950
951
    /**
952
     * Return's the attributes for the attribute set of the product that has to be created.
@@ 957-980 (lines=24) @@
954
     * @return array The attributes
955
     * @throws \Exception Is thrown if the attributes for the actual attribute set are not available
956
     */
957
    public function getAttributes()
958
    {
959
960
        // query whether or not, the requested EAV attributes are available
961
        if (isset($this->attributes[$entityTypeCode = $this->getEntityTypeCode()])) {
962
            // load the attributes for the entity type code
963
            $attributes = $this->attributes[$entityTypeCode];
964
965
            // query whether or not attributes for the actual attribute set name
966
            if (isset($attributes[$attributeSetName = $this->attributeSet[MemberNames::ATTRIBUTE_SET_NAME]])) {
967
                return $attributes[$attributeSetName];
968
            }
969
        }
970
971
        // throw an exception, if not
972
        throw new \Exception(
973
            sprintf(
974
                'Found invalid attribute set name "%s" in file %s on line %d',
975
                $attributeSetName,
976
                $this->getFilename(),
977
                $this->getLineNumber()
978
            )
979
        );
980
    }
981
982
    /**
983
     * Return's the EAV attribute with the passed attribute code.