/** * @param mixed $data * @return ConsentList */ public static function createListFromMetadata($data) { Assert::isArray($data, 'Consent list JSON structure must be an associative array, got %s'); // We cannot use self::class because translation extractions fails on that $consents = array_map(['\\OpenConext\\EngineBlockApiClientBundle\\Value\\ConsentListFactory', 'createConsent'], $data); return new ConsentList($consents); }
/** * @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'])); }