Code Duplication    Length = 17-22 lines in 3 locations

src/Webservice/Proxy/ProxyFactory.php 3 locations

@@ 76-97 (lines=22) @@
73
        };
74
    }
75
    
76
    private function fetchBelongsTo(
77
        TransferMetadata $metadata,
78
        PropertyMetadata $propertyMetadata,
79
        TransferManagerInterface $transferManager,
80
        $object,
81
        string $type
82
    ) {
83
        $belongsTo = $propertyMetadata->getAnnotation(BelongsTo::class);
84
        
85
        if ($belongsTo instanceof BelongsTo && empty($propertyMetadata->getValue($object))) {
86
            $idValue  = $metadata->propertyMetadata[$belongsTo->foreignField]->getValue($object);
87
            
88
            if (!$idValue) {
89
                return;
90
            }
91
            
92
            $data = $transferManager
93
                ->find($type, $idValue);
94
95
            $propertyMetadata->setValue($object, $data);
96
        }
97
    }
98
99
    private function fetchHasOne(
100
        TransferMetadata $metadata,
@@ 99-115 (lines=17) @@
96
        }
97
    }
98
99
    private function fetchHasOne(
100
        TransferMetadata $metadata,
101
        PropertyMetadata $propertyMetadata,
102
        TransferManagerInterface $transferManager,
103
        $object,
104
        string $type
105
    ) {
106
        $hasOne = $propertyMetadata->getAnnotation(HasOne::class);
107
        $id     = $metadata->id->getValue($object);
108
        
109
        if ($hasOne instanceof HasOne && !empty($id)) {
110
            $data = $transferManager->getRepository($type)
111
                ->findOneBy([$hasOne->foreignField => $id]);
112
113
            $propertyMetadata->setValue($object, $data);
114
        }
115
    }
116
117
    private function fetchHasMany(
118
        TransferMetadata $metadata,
@@ 117-133 (lines=17) @@
114
        }
115
    }
116
117
    private function fetchHasMany(
118
        TransferMetadata $metadata,
119
        PropertyMetadata $propertyMetadata,
120
        TransferManagerInterface $transferManager,
121
        $object,
122
        string $type
123
    ) {
124
        $hasMany = $propertyMetadata->getAnnotation(HasMany::class);
125
        $id      = $metadata->id->getValue($object);
126
127
        if ($hasMany instanceof HasMany && !empty($id)) {
128
            $data = $transferManager->getRepository($type)
129
                ->findBy([$hasMany->foreignField => $metadata->id->getValue($object)]);
130
131
            $propertyMetadata->setValue($object, $data);
132
        }
133
    }
134
135
    public function registerProxyAutoloader()
136
    {