Code Duplication    Length = 16-17 lines in 3 locations

core/domain/services/graphql/data/mutations/DatetimeMutation.php 1 location

@@ 106-121 (lines=16) @@
103
     * @throws InvalidArgumentException
104
     * @throws ReflectionException
105
     */
106
    public static function setRelatedTickets($entity, array $tickets)
107
    {
108
        $relationName = 'Ticket';
109
        // Remove all the existing related tickets
110
        $entity->_remove_relations($relationName);
111
112
        foreach ($tickets as $ID) {
113
            $parts = Relay::fromGlobalId($ID);
114
            if (! empty($parts['id']) && absint($parts['id'])) {
115
                $entity->_add_relation_to(
116
                    $parts['id'],
117
                    $relationName
118
                );
119
            }
120
        }
121
    }
122
}
123

core/domain/services/graphql/data/mutations/TicketMutation.php 2 locations

@@ 146-162 (lines=17) @@
143
     * @throws InvalidInterfaceException
144
     * @throws ReflectionException
145
     */
146
    public static function setRelatedDatetimes($entity, array $datetimes)
147
    {
148
        $relationName = 'Datetime';
149
        // Remove all the existing related datetimes
150
151
        $entity->_remove_relations($relationName);
152
        // @todo replace loop with single query
153
        foreach ($datetimes as $ID) {
154
            $parts = Relay::fromGlobalId($ID);
155
            if (! empty($parts['id']) && absint($parts['id'])) {
156
                $entity->_add_relation_to(
157
                    $parts['id'],
158
                    $relationName
159
                );
160
            }
161
        }
162
    }
163
164
165
    /**
@@ 176-192 (lines=17) @@
173
     * @throws InvalidInterfaceException
174
     * @throws ReflectionException
175
     */
176
    public static function setRelatedPrices($entity, array $prices)
177
    {
178
        $relationName = 'Price';
179
        // Remove all the existing related entities
180
        $entity->_remove_relations($relationName);
181
182
        // @todo replace loop with single query
183
        foreach ($prices as $ID) {
184
            $parts = Relay::fromGlobalId($ID);
185
            if (! empty($parts['id']) && absint($parts['id'])) {
186
                $entity->_add_relation_to(
187
                    $parts['id'],
188
                    $relationName
189
                );
190
            }
191
        }
192
    }
193
194
195
    /**