<commit_before><?php

//namespace Alexa_Quote;

class Alexa_Briefing {
	public function briefing_request() {
		$response = [];

		$briefing = get_posts( [
			'meta_query' => [
				[
					'key' => 'alexawp_briefing_source',
					'compare' => '!=',
					'value' => '',
				],
			],
			'no_found_rows' => true,
			'post_status' => 'publish',
			'post_type' => 'alexawp-briefing',
			'posts_per_page' => 1,
			'suppress_filters' => false,
		] );

		if ( $briefing ) {
			$post = reset( $briefing );

			$response = [
				'uid' => get_post_meta( $post->ID, 'alexawp_briefing_uuid', true ),
				'updateDate' => get_post_modified_time( 'Y-m-d\TH:i:s.\0\Z', true, $post ),
				'titleText' => get_the_title( $post ),
				'mainText' => '',
				'redirectionUrl' => home_url(),
			];

			switch ( get_post_meta( $post->ID, 'alexawp_briefing_source', true ) ) {
				case 'text' :
					$response['mainText'] = get_post_meta( $post->ID, 'alexawp_briefing_text', true );
				break;

				case 'attachment_id' :
					$response['streamUrl'] = wp_get_attachment_url( get_post_meta( $post->ID, 'alexawp_briefing_attachment_id', true ) );
				break;

				case 'audio_url' :
					$response['streamUrl'] = esc_url_raw( get_post_meta( $post->ID, 'alexawp_briefing_audio_url', true ) );
				break;
			}
		}

		return $response;
	}<commit_msg>Prepare for the possibility of multiple items in the briefing<commit_after><?php

//namespace Alexa_Quote;

class Alexa_Briefing {
	public function briefing_request() {
		$responses = [];

		$briefings = get_posts( [
			'meta_query' => [
				[
					'key' => 'alexawp_briefing_source',
					'compare' => '!=',
					'value' => '',
				],
			],
			'no_found_rows' => true,
			'post_status' => 'publish',
			'post_type' => 'alexawp-briefing',
			'posts_per_page' => 1,
			'suppress_filters' => false,
		] );

		// This logic could be both abstracted and used with array_map().
		foreach ( $briefings as $post ) {
			$response = [
				'uid' => get_post_meta( $post->ID, 'alexawp_briefing_uuid', true ),
				'updateDate' => get_post_modified_time( 'Y-m-d\TH:i:s.\0\Z', true, $post ),
				'titleText' => get_the_title( $post ),
				'mainText' => '',
				'redirectionUrl' => home_url(),
			];

			switch ( get_post_meta( $post->ID, 'alexawp_briefing_source', true ) ) {
				case 'text' :
					$response['mainText'] = get_post_meta( $post->ID, 'alexawp_briefing_text', true );
				break;

				case 'attachment_id' :
					$response['streamUrl'] = wp_get_attachment_url( get_post_meta( $post->ID, 'alexawp_briefing_attachment_id', true ) );
				break;

				case 'audio_url' :
					$response['streamUrl'] = esc_url_raw( get_post_meta( $post->ID, 'alexawp_briefing_audio_url', true ) );
				break;
			}

			$responses[] = $response;
		}

		// Unclear whether an array with a single response is acceptable.
		if ( count( $responses ) === 1 ) {
			$responses = $responses[0];
		}

		return $responses;
	}
{'fraction_non_alphanumeric': 0.17314974182444062, 'fraction_numerical': 0.002065404475043029, 'mean_word_length': 3.477657935285054, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1309950', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1066, 'n_words': 198}