public function save(Pet $pet) { $petArray = ['age' => $petOwner->getAge(), 'hunger' => $petOwner->getHunger(), 'stress' => $petOwner->getStress(), 'alive' => $petOwner->getAlive()]; try { if ($pet->getNewborn()) { $this->insert('pet', $petArray); } else { $this->update('pet', $petArray, "pet_id = {$pet->getId}"); } } catch (Exception $e) { throw new Exception($e->getMessage()); } }