Code Duplication    Length = 18-22 lines in 2 locations

src/Handler/BindCommandHandler.php 1 location

@@ 438-455 (lines=18) @@
435
     *
436
     * @return BindingDescriptor
437
     */
438
    private function getBindingByUuidPrefix($uuidPrefix)
439
    {
440
        $expr = Expr::method('getUuid', Expr::startsWith($uuidPrefix));
441
        $descriptors = $this->discoveryManager->findBindingDescriptors($expr);
442
443
        if (0 === count($descriptors)) {
444
            throw new RuntimeException(sprintf('The binding "%s" does not exist.', $uuidPrefix));
445
        }
446
447
        if (count($descriptors) > 1) {
448
            throw new RuntimeException(sprintf(
449
                'More than one binding matches the UUID prefix "%s".',
450
                $uuidPrefix
451
            ));
452
        }
453
454
        return reset($descriptors);
455
    }
456
457
    private function bindingsEqual(BindingDescriptor $descriptor1, BindingDescriptor $descriptor2)
458
    {

src/Handler/PublishCommandHandler.php 1 location

@@ 269-290 (lines=22) @@
266
     *
267
     * @return AssetMapping
268
     */
269
    private function getMappingByUuidPrefix($uuidPrefix)
270
    {
271
        $expr = Expr::method('getUuid', Expr::startsWith($uuidPrefix));
272
273
        $mappings = $this->assetManager->findAssetMappings($expr);
274
275
        if (!$mappings) {
276
            throw new RuntimeException(sprintf(
277
                'The mapping with the UUID prefix "%s" does not exist.',
278
                $uuidPrefix
279
            ));
280
        }
281
282
        if (count($mappings) > 1) {
283
            throw new RuntimeException(sprintf(
284
                'More than one mapping matches the UUID prefix "%s".',
285
                $uuidPrefix
286
            ));
287
        }
288
289
        return reset($mappings);
290
    }
291
292
    private function mappingsEqual(AssetMapping $mapping1, AssetMapping $mapping2)
293
    {