| Conditions | 8 |
| Paths | 5 |
| Total Lines | 33 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | public function fetchLatestRelease(): array |
||
| 28 | { |
||
| 29 | $nextVersion = Platform::getEnv('SW_RECOVERY_NEXT_VERSION'); |
||
| 30 | if (\is_string($nextVersion)) { |
||
|
|
|||
| 31 | return [ |
||
| 32 | '6.4' => '6.4.17.2', |
||
| 33 | '6.5' => $nextVersion, |
||
| 34 | ]; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** @var array{packages: array{"shopware/core": array{version: string}[]}} $response */ |
||
| 38 | $response = $this->client->request('GET', 'https://repo.packagist.org/p2/shopware/core.json')->toArray(); |
||
| 39 | |||
| 40 | $versions = array_column($response['packages']['shopware/core'], 'version'); |
||
| 41 | |||
| 42 | // Index them by major version |
||
| 43 | $mappedVersions = []; |
||
| 44 | |||
| 45 | foreach ($versions as $version) { |
||
| 46 | if (str_contains($version, 'dev-') || str_contains($version, 'alpha') || str_contains($version, 'beta') || str_contains($version, 'rc')) { |
||
| 47 | continue; |
||
| 48 | } |
||
| 49 | |||
| 50 | $major = substr($version, 0, 3); |
||
| 51 | |||
| 52 | if (isset($mappedVersions[$major])) { |
||
| 53 | continue; |
||
| 54 | } |
||
| 55 | |||
| 56 | $mappedVersions[$major] = $version; |
||
| 57 | } |
||
| 58 | |||
| 59 | return $mappedVersions; |
||
| 60 | } |
||
| 62 |