Code Duplication    Length = 14-14 lines in 2 locations

src/Package/PackageCollection.php 2 locations

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