12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace Fgm\ComposerCheck;
- /**
- * Class LockLoader loads a composer.lock file.
- */
- class LockLoader extends LoaderBase implements LoaderInterface {
- protected $platform = [];
- /**
- * {@inheritdoc}
- */
- public function __construct(string $directory) {
- $this->file = realpath("${directory}/composer.lock");
- }
- public function parse() {
- $lockPackages = $this->contents['packages'];
- $lockDevPackages = $this->contents['packages-dev'];
- $lockPlatform = $this->contents['platform'];
- array_walk($lockPlatform, function (&$requirement, $component) {
- $requirement = [
- 'name' => $component,
- 'version' => $requirement,
- ];
- });
- $this->run = array_merge($lockPackages, $lockPlatform);
- $this->dev = array_merge($lockDevPackages, $lockPlatform);
- }
- }
|