public function getImageByCode($code) { foreach ($this->images as $image) { if ($code === $image->getCode()) { return $image; } } return null; }