Code Duplication    Length = 26-26 lines in 3 locations

src/POData/Providers/Metadata/SimpleMetadataProvider.php 3 locations

@@ 538-563 (lines=26) @@
535
     * @param string $sourceProperty            The name of the property to add, on source type
536
     * @param string $targetProperty            The name of the property to add, on target type
537
     */
538
    public function addResourceReferencePropertyBidirectional(
539
        ResourceEntityType $sourceResourceType,
540
        ResourceEntityType $targetResourceType,
541
        $sourceProperty,
542
        $targetProperty
543
    ) {
544
        $this->_addReferencePropertyInternalBidirectional(
545
            $sourceResourceType,
546
            $targetResourceType,
547
            $sourceProperty,
548
            $targetProperty,
549
            '*',
550
            '1'
551
        );
552
        // verify resource property types are what we expect them to be
553
        $sourceResourceKind = $sourceResourceType->resolveProperty($sourceProperty)->getKind();
554
        assert(
555
            ResourcePropertyKind::RESOURCESET_REFERENCE == $sourceResourceKind,
556
            "1 side of 1:N relationship not pointing to resource set reference"
557
        );
558
        $targetResourceKind = $targetResourceType->resolveProperty($targetProperty)->getKind();
559
        assert(
560
            ResourcePropertyKind::RESOURCE_REFERENCE == $targetResourceKind,
561
            "N side of 1:N relationship not pointing to resource reference"
562
        );
563
    }
564
565
    /**
566
     * To add a navigation property (resource set or resource reference)
@@ 782-807 (lines=26) @@
779
     * @param string                $sourceProperty         The name of the property to add, on source type
780
     * @param string                $targetProperty         The name of the property to add, on target type
781
     */
782
    public function addResourceSetReferencePropertyBidirectional(
783
        ResourceEntityType $sourceResourceType,
784
        ResourceEntityType $targetResourceType,
785
        $sourceProperty,
786
        $targetProperty
787
    ) {
788
        $this->_addReferencePropertyInternalBidirectional(
789
            $sourceResourceType,
790
            $targetResourceType,
791
            $sourceProperty,
792
            $targetProperty,
793
            '*',
794
            '*'
795
        );
796
        // verify resource property types are what we expect them to be
797
        $sourceResourceKind = $sourceResourceType->resolveProperty($sourceProperty)->getKind();
798
        assert(
799
            ResourcePropertyKind::RESOURCESET_REFERENCE == $sourceResourceKind,
800
            "M side of M:N relationship not pointing to resource set reference"
801
        );
802
        $targetResourceKind = $targetResourceType->resolveProperty($targetProperty)->getKind();
803
        assert(
804
            ResourcePropertyKind::RESOURCESET_REFERENCE == $targetResourceKind,
805
            "N side of M:N relationship not pointing to resource set reference"
806
        );
807
    }
808
809
    /**
810
     * To add a 1-1 resource reference.
@@ 819-844 (lines=26) @@
816
     * @param string                $sourceProperty         The name of the property to add, on source type
817
     * @param string                $targetProperty         The name of the property to add, on target type
818
     */
819
    public function addResourceReferenceSinglePropertyBidirectional(
820
        ResourceEntityType $sourceResourceType,
821
        ResourceEntityType $targetResourceType,
822
        $sourceProperty,
823
        $targetProperty
824
    ) {
825
        $this->_addReferencePropertyInternalBidirectional(
826
            $sourceResourceType,
827
            $targetResourceType,
828
            $sourceProperty,
829
            $targetProperty,
830
            '1',
831
            '0..1'
832
        );
833
        // verify resource property types are what we expect them to be
834
        $sourceResourceKind = $sourceResourceType->resolveProperty($sourceProperty)->getKind();
835
        assert(
836
            ResourcePropertyKind::RESOURCE_REFERENCE == $sourceResourceKind,
837
            "0..1 side of 1:1 relationship not pointing to resource reference"
838
        );
839
        $targetResourceKind = $targetResourceType->resolveProperty($targetProperty)->getKind();
840
        assert(
841
            ResourcePropertyKind::RESOURCE_REFERENCE == $targetResourceKind,
842
            "1 side of 1:1 relationship not pointing to resource reference"
843
        );
844
    }
845
846
    /**
847
     * To add a complex property to entity or complex type.