/** * {@inheritdoc} */ public static function fromArray(array $values) { $message = new self(); $values = array_merge(['send_marketing_emails' => null, 'send_push_notifications' => null], $values); $message->setSendMarketingEmails($values['send_marketing_emails']); $message->setSendPushNotifications($values['send_push_notifications']); return $message; }
/** * {@inheritdoc} */ public static function fromArray(array $values) { $message = new self(); $values = array_merge(['tutorials_completed' => [], 'send_marketing_emails' => null, 'send_push_notifications' => null], $values); $message->setSendMarketingEmails($values['send_marketing_emails']); $message->setSendPushNotifications($values['send_push_notifications']); foreach ($values['tutorials_completed'] as $item) { $message->addTutorialsCompleted($item); } return $message; }
/** * @param Profile $profile * @param string $data * @return Contact * @throws InvalidArgumentException */ public static function unserialize($profile, $data) { if (!$profile instanceof Profile) { throw new InvalidArgumentException("Expected Profile instance"); } $parts = str_split($data); if (count($parts) < 2) { throw new InvalidArgumentException("Invalid contact parts"); } $contact = new self($profile); $contact->setSendMarketingEmails($parts[0] != 0); $contact->setSendPushNotifications($parts[1] != 0); return $contact; }