protected function keyUnitsById() { $keyed_units = array(); foreach ($this->units as $unit) { $keyed_units[$unit->getUnitId()] = $unit; } return $keyed_units; }