Code Duplication    Length = 17-18 lines in 2 locations

src/Package/PackageJsonSerializer.php 2 locations

@@ 124-140 (lines=17) @@
121
    /**
122
     * {@inheritdoc}
123
     */
124
    public function serializePackageFile(PackageFile $packageFile)
125
    {
126
        $this->assertVersionSupported($packageFile->getVersion());
127
128
        $jsonData = (object) array('version' => $this->targetVersion);
129
130
        $this->packageFileToJson($packageFile, $jsonData);
131
132
        // Sort according to key order
133
        $jsonArray = (array) $jsonData;
134
        $orderedKeys = array_intersect_key(array_flip(self::$keyOrder), $jsonArray);
135
        $jsonData = (object) array_replace($orderedKeys, $jsonArray);
136
137
        $this->migrationManager->migrate($jsonData, $packageFile->getVersion());
138
139
        return $this->encode($jsonData, $packageFile->getPath());
140
    }
141
142
    /**
143
     * {@inheritdoc}
@@ 145-162 (lines=18) @@
142
    /**
143
     * {@inheritdoc}
144
     */
145
    public function serializeRootPackageFile(RootPackageFile $packageFile)
146
    {
147
        $this->assertVersionSupported($packageFile->getVersion());
148
149
        $jsonData = (object) array('version' => $this->targetVersion);
150
151
        $this->packageFileToJson($packageFile, $jsonData);
152
        $this->rootPackageFileToJson($packageFile, $jsonData);
153
154
        // Sort according to key order
155
        $jsonArray = (array) $jsonData;
156
        $orderedKeys = array_intersect_key(array_flip(self::$keyOrder), $jsonArray);
157
        $jsonData = (object) array_replace($orderedKeys, $jsonArray);
158
159
        $this->migrationManager->migrate($jsonData, $packageFile->getVersion());
160
161
        return $this->encode($jsonData, $packageFile->getPath());
162
    }
163
164
    /**
165
     * {@inheritdoc}