| @@ 65-79 (lines=15) @@ | ||
| 62 | /** |
|
| 63 | * {@inheritdoc} |
|
| 64 | */ |
|
| 65 | public function toJson($packageFile, array $options = array()) |
|
| 66 | { |
|
| 67 | Assert::isInstanceOf($packageFile, 'Puli\Manager\Api\Package\PackageFile'); |
|
| 68 | ||
| 69 | $jsonData = new stdClass(); |
|
| 70 | ||
| 71 | $this->addPackageFileToJson($packageFile, $jsonData); |
|
| 72 | ||
| 73 | // Sort according to key order |
|
| 74 | $jsonArray = (array) $jsonData; |
|
| 75 | $orderedKeys = array_intersect_key(array_flip(self::$keyOrder), $jsonArray); |
|
| 76 | $jsonData = (object) array_replace($orderedKeys, $jsonArray); |
|
| 77 | ||
| 78 | return $jsonData; |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * {@inheritdoc} |
|
| @@ 52-66 (lines=15) @@ | ||
| 49 | /** |
|
| 50 | * {@inheritdoc} |
|
| 51 | */ |
|
| 52 | public function toJson($packageFile, array $options = array()) |
|
| 53 | { |
|
| 54 | Assert::isInstanceOf($packageFile, 'Puli\Manager\Api\Package\RootPackageFile'); |
|
| 55 | ||
| 56 | $jsonData = new stdClass(); |
|
| 57 | ||
| 58 | $this->addPackageFileToJson($packageFile, $jsonData); |
|
| 59 | $this->addRootPackageFileToJson($packageFile, $jsonData); |
|
| 60 | ||
| 61 | // Sort according to key order |
|
| 62 | $jsonArray = (array) $jsonData; |
|
| 63 | $orderedKeys = array_intersect_key(array_flip(self::$keyOrder), $jsonArray); |
|
| 64 | ||
| 65 | return (object) array_replace($orderedKeys, $jsonArray); |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * {@inheritdoc} |
|