/** * @param Customer $customer * * @return array * * @throws UnsupportedClassException */ public function serialize($customer) : array { if (!$customer instanceof Customer) { throw new UnsupportedClassException(); } return ['id' => $customer->getId(), 'name' => $customer->getName()]; }