12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace Fgm\ComposerCheck;
- class LockLoader implements LoaderInterface {
- protected $file;
- protected $platform = [];
- protected $dev = [];
- protected $run = [];
-
- public function __construct(string $directory) {
- $this->file = realpath("${directory}/composer.lock");
- }
-
- public function getDev() {
- return $this->dev;
- }
-
- public function getRun() {
- return $this->run;
- }
-
- public function load() {
- $lockFile = json_decode(file_get_contents($this->file), TRUE);
- $lockPackages = $lockFile['packages'];
- $lockDevPackages = $lockFile['packages-dev'];
- $lockPlatform = $lockFile['platform'];
- array_walk($lockPlatform, function (&$requirement, $component) {
- $requirement = [
- 'name' => $component,
- 'version' => $requirement,
- ];
- });
- $this->run = array_merge($lockPackages, $lockPlatform);
- $this->dev = array_merge($lockDevPackages, $lockPlatform);
- }
- }
|