Code Duplication    Length = 23-23 lines in 5 locations

src/SchemaReader.php 5 locations

@@ 868-890 (lines=23) @@
865
        );
866
    }
867
868
    private function findAttributeItem(Schema $schema, DOMElement $node, string $typeName): AttributeItem
869
    {
870
        list($name, $namespace) = static::splitParts($node, $typeName);
871
872
        $namespace = $namespace ?: $schema->getTargetNamespace();
873
874
        try {
875
            return $schema->findAttribute($name, $namespace);
876
        } catch (TypeNotFoundException $e) {
877
            throw new TypeException(
878
                sprintf(
879
                    "Can't find %s named {%s}#%s, at line %d in %s ",
880
                    'attribute',
881
                    $namespace,
882
                    $name,
883
                    $node->getLineNo(),
884
                    $node->ownerDocument->documentURI
885
                ),
886
                0,
887
                $e
888
            );
889
        }
890
    }
891
892
    private function findAttributeGroup(Schema $schema, DOMElement $node, string $typeName): AttributeGroup
893
    {
@@ 892-914 (lines=23) @@
889
        }
890
    }
891
892
    private function findAttributeGroup(Schema $schema, DOMElement $node, string $typeName): AttributeGroup
893
    {
894
        list($name, $namespace) = static::splitParts($node, $typeName);
895
896
        $namespace = $namespace ?: $schema->getTargetNamespace();
897
898
        try {
899
            return $schema->findAttributeGroup($name, $namespace);
900
        } catch (TypeNotFoundException $e) {
901
            throw new TypeException(
902
                sprintf(
903
                    "Can't find %s named {%s}#%s, at line %d in %s ",
904
                    'attributegroup',
905
                    $namespace,
906
                    $name,
907
                    $node->getLineNo(),
908
                    $node->ownerDocument->documentURI
909
                ),
910
                0,
911
                $e
912
            );
913
        }
914
    }
915
916
    private function findElement(Schema $schema, DOMElement $node, string $typeName): ElementDef
917
    {
@@ 916-938 (lines=23) @@
913
        }
914
    }
915
916
    private function findElement(Schema $schema, DOMElement $node, string $typeName): ElementDef
917
    {
918
        list($name, $namespace) = static::splitParts($node, $typeName);
919
920
        $namespace = $namespace ?: $schema->getTargetNamespace();
921
922
        try {
923
            return $schema->findElement($name, $namespace);
924
        } catch (TypeNotFoundException $e) {
925
            throw new TypeException(
926
                sprintf(
927
                    "Can't find %s named {%s}#%s, at line %d in %s ",
928
                    'element',
929
                    $namespace,
930
                    $name,
931
                    $node->getLineNo(),
932
                    $node->ownerDocument->documentURI
933
                ),
934
                0,
935
                $e
936
            );
937
        }
938
    }
939
940
    private function findGroup(Schema $schema, DOMElement $node, string $typeName): Group
941
    {
@@ 940-962 (lines=23) @@
937
        }
938
    }
939
940
    private function findGroup(Schema $schema, DOMElement $node, string $typeName): Group
941
    {
942
        list($name, $namespace) = static::splitParts($node, $typeName);
943
944
        $namespace = $namespace ?: $schema->getTargetNamespace();
945
946
        try {
947
            return $schema->findGroup($name, $namespace);
948
        } catch (TypeNotFoundException $e) {
949
            throw new TypeException(
950
                sprintf(
951
                    "Can't find %s named {%s}#%s, at line %d in %s ",
952
                    'group',
953
                    $namespace,
954
                    $name,
955
                    $node->getLineNo(),
956
                    $node->ownerDocument->documentURI
957
                ),
958
                0,
959
                $e
960
            );
961
        }
962
    }
963
964
    private function findType(Schema $schema, DOMElement $node, string $typeName): SchemaItem
965
    {
@@ 964-986 (lines=23) @@
961
        }
962
    }
963
964
    private function findType(Schema $schema, DOMElement $node, string $typeName): SchemaItem
965
    {
966
        list($name, $namespace) = static::splitParts($node, $typeName);
967
968
        $namespace = $namespace ?: $schema->getTargetNamespace();
969
970
        try {
971
            return $schema->findType($name, $namespace);
972
        } catch (TypeNotFoundException $e) {
973
            throw new TypeException(
974
                sprintf(
975
                    "Can't find %s named {%s}#%s, at line %d in %s ",
976
                    'type',
977
                    $namespace,
978
                    $name,
979
                    $node->getLineNo(),
980
                    $node->ownerDocument->documentURI
981
                ),
982
                0,
983
                $e
984
            );
985
        }
986
    }
987
988
    /**
989
     * @return Closure