Skip to content

Commit 2afe337

Browse files
cy-yunbshaffer
andauthored
Update pubsub/api/src/create_topic_with_cloud_storage_ingestion.php
Co-authored-by: Brent Shaffer <[email protected]>
1 parent 8b22b94 commit 2afe337

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

pubsub/api/src/create_topic_with_cloud_storage_ingestion.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,14 @@ function create_topic_with_cloud_storage_ingestion(
5959
'minimum_object_create_time' => $timestamp
6060
];
6161

62-
switch ($inputFormat) {
63-
case 'text':
64-
$cloudStorageData['text_format'] = new TextFormat(['delimiter' => $textDelimeter]);
65-
break;
66-
case 'avro':
67-
$cloudStorageData['avro_format'] = new AvroFormat();
68-
break;
69-
case 'pubsub_avro':
70-
$cloudStorageData['pubsub_avro_format'] = new PubSubAvroFormat();
71-
break;
72-
default:
73-
throw new \InvalidArgumentException('inputFormat must be in (\'text\', \'avro\', \'pubsub_avro\'); got value: ' . $inputFormat);
74-
}
62+
$cloudStorageData[$inputFormat . '_format'] = match($inputFormat) {
63+
'text' => new TextFormat(['delimiter' => $textDelimiter]),
64+
'avro' => new AvroFormat(),
65+
'pubsub_avro' => new PubSubAvroFormat(),
66+
default => throw new \InvalidArgumentException(
67+
'inputFormat must be in (\'text\', \'avro\', \'pubsub_avro\'); got value: ' . $inputFormat
68+
)
69+
};
7570

7671
if (!empty($matchGlob)) {
7772
$cloudStorageData['match_glob'] = $matchGlob;

0 commit comments

Comments
 (0)