/**
  * @param mixed $data
  * @return ContactPerson
  *
  * @SuppressWarnings(PHPMD.UnusedPrivateMethod)
  */
 private static function createContactPerson($data)
 {
     Assert::isArray($data, 'Contact person JSON structure must be an associative array, got %s');
     Assert::keyExists($data, 'contact_type', 'Contact person JSON structure must contain key "contact_type"');
     if (!array_key_exists('email_address', $data)) {
         return new ContactPerson(new ContactType($data['contact_type']));
     }
     return new ContactPerson(new ContactType($data['contact_type']), new ContactEmailAddress($data['email_address']));
 }
 /**
  * @param mixed $data
  * @return ServiceProvider
  */
 private static function createServiceProvider($data)
 {
     Assert::keyExists($data, 'entity_id', 'Consent JSON structure must contain key "entity_id"');
     Assert::keyExists($data, 'display_name', 'Consent JSON structure must contain key "display_name"');
     Assert::keyExists($data, 'eula_url', 'Consent JSON structure must contain key "eula_url"');
     Assert::keyExists($data, 'support_email', 'Consent JSON structure must contain key "support_email"');
     $entity = new Entity(new EntityId($data['entity_id']), EntityType::SP());
     $displayName = new DisplayName($data['display_name']);
     $eulaUrl = null;
     $supportEmail = null;
     if ($data['eula_url'] !== null) {
         $eulaUrl = new Url($data['eula_url']);
     }
     if ($data['support_email'] !== null) {
         $supportEmail = new ContactEmailAddress($data['support_email']);
     }
     return new ServiceProvider($entity, $displayName, $eulaUrl, $supportEmail);
 }