Code Duplication    Length = 18-18 lines in 3 locations

src/Package/RootPackageFileManagerImpl.php 3 locations

@@ 100-117 (lines=18) @@
97
    /**
98
     * {@inheritdoc}
99
     */
100
    public function setPackageName($packageName)
101
    {
102
        if ($packageName === $this->rootPackageFile->getPackageName()) {
103
            return;
104
        }
105
106
        $previousName = $this->rootPackageFile->getPackageName();
107
108
        $this->rootPackageFile->setPackageName($packageName);
109
110
        try {
111
            $this->packageFileStorage->saveRootPackageFile($this->rootPackageFile);
112
        } catch (Exception $e) {
113
            $this->rootPackageFile->setPackageName($previousName);
114
115
            throw $e;
116
        }
117
    }
118
119
    /**
120
     * {@inheritdoc}
@@ 371-388 (lines=18) @@
368
    /**
369
     * {@inheritdoc}
370
     */
371
    public function clearExtraKeys()
372
    {
373
        $previousValues = $this->rootPackageFile->getExtraKeys();
374
375
        if (!$previousValues) {
376
            return;
377
        }
378
379
        $this->rootPackageFile->clearExtraKeys();
380
381
        try {
382
            $this->packageFileStorage->saveRootPackageFile($this->rootPackageFile);
383
        } catch (Exception $e) {
384
            $this->rootPackageFile->setExtraKeys($previousValues);
385
386
            throw $e;
387
        }
388
    }
389
390
    /**
391
     * {@inheritdoc}
@@ 451-468 (lines=18) @@
448
    /**
449
     * {@inheritdoc}
450
     */
451
    public function migrate($targetVersion)
452
    {
453
        $previousVersion = $this->rootPackageFile->getVersion();
454
455
        if ($previousVersion === $targetVersion) {
456
            return;
457
        }
458
459
        $this->rootPackageFile->setVersion($targetVersion);
460
461
        try {
462
            $this->packageFileStorage->saveRootPackageFile($this->rootPackageFile);
463
        } catch (Exception $e) {
464
            $this->rootPackageFile->setVersion($previousVersion);
465
466
            throw $e;
467
        }
468
    }
469
470
    /**
471
     * {@inheritdoc}