private function addUserToCartIfExists(Cart &$cart, UuidInterface $userId = null) { if (!empty($userId)) { $user = $this->userRepository->findOneById($userId); $cart->setUser($user); } }