Code Duplication    Length = 14-14 lines in 3 locations

src/InstalledPackagesFile.php 1 location

@@ 24-37 (lines=14) @@
21
        return new self($root, JsonObject::fromFilePath($filePath));
22
    }
23
24
    public function getPackages() : PackageCollection
25
    {
26
        if (null === $this->packages) {
27
            $packages = [];
28
            $packagesData = $this->json->get();
29
            foreach ($packagesData as $packageData) {
30
                $package = Package::fromArray($this->root, $packageData);
31
                $packages[$package->getName()] = $package;
32
            }
33
            $this->packages = new PackageCollection($packages);
34
        }
35
36
        return $this->packages;
37
    }
38
39
    public function get($keys = [], $default = null)
40
    {

src/LockFile.php 2 locations

@@ 24-37 (lines=14) @@
21
        return new self($root, JsonObject::fromFilePath($filePath));
22
    }
23
24
    public function getPackages() : PackageCollection
25
    {
26
        if (null === $this->packages) {
27
            $packages = [];
28
            $packagesData = $this->json->get(['packages'], []);
29
            foreach ($packagesData as $packageData) {
30
                $package = Package::fromArray($this->root, $packageData);
31
                $packages[$package->getName()] = $package;
32
            }
33
            $this->packages = new PackageCollection($packages);
34
        }
35
36
        return $this->packages;
37
    }
38
39
    public function getDevPackages() : PackageCollection
40
    {
@@ 39-52 (lines=14) @@
36
        return $this->packages;
37
    }
38
39
    public function getDevPackages() : PackageCollection
40
    {
41
        if (null === $this->packages) {
42
            $packages = [];
43
            $packagesData = $this->json->get(['packages-dev'], []);
44
            foreach ($packagesData as $packageData) {
45
                $package = Package::fromArray($this->root, $packageData);
46
                $packages[$package->getName()] = $package;
47
            }
48
            $this->packages = new PackageCollection($packages);
49
        }
50
51
        return $this->packages;
52
    }
53
54
    public function get($keys = [], $default = null)
55
    {