LockLoader.php 820 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Fgm\ComposerCheck;
  3. /**
  4. * Class LockLoader loads a composer.lock file.
  5. */
  6. class LockLoader extends LoaderBase implements LoaderInterface {
  7. protected $platform = [];
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function __construct(string $directory) {
  12. $this->file = realpath("${directory}/composer.lock");
  13. }
  14. public function parse() {
  15. $lockPackages = $this->contents['packages'];
  16. $lockDevPackages = $this->contents['packages-dev'];
  17. $lockPlatform = $this->contents['platform'];
  18. array_walk($lockPlatform, function (&$requirement, $component) {
  19. $requirement = [
  20. 'name' => $component,
  21. 'version' => $requirement,
  22. ];
  23. });
  24. $this->run = array_merge($lockPackages, $lockPlatform);
  25. $this->dev = array_merge($lockDevPackages, $lockPlatform);
  26. }
  27. }