Code Duplication    Length = 14-14 lines in 2 locations

src/Package/PackageCollection.php 2 locations

@@ 80-93 (lines=14) @@
77
    /**
78
     * @return array
79
     */
80
    private function getIndexedByName(): array
81
    {
82
        if (!empty($this->indexedBy['name'])) {
83
            return $this->indexedBy['name'];
84
        }
85
        /** @var Package $package */
86
        foreach($this->getArrayCopy() as $package) {
87
            if (!($package instanceof Package)) {
88
                continue;
89
            }
90
            $this->indexedBy['name'][$package->getName()] = $package;
91
        }
92
        return $this->indexedBy['name'];
93
    }
94
95
    /**
96
     * @return array
@@ 98-111 (lines=14) @@
95
    /**
96
     * @return array
97
     */
98
    private function getIndexedByNamespace(): array
99
    {
100
        if (!empty($this->indexedBy['namespace'])) {
101
            return $this->indexedBy['namespace'];
102
        }
103
        /** @var Package $package */
104
        foreach($this->getArrayCopy() as $package) {
105
            if (!($package instanceof Package)) {
106
                continue;
107
            }
108
            $this->indexedBy['namespace'][$package->getNamespace()] = $package;
109
        }
110
        return $this->indexedBy['namespace'];
111
    }
112
}
113