Yoast\WP\SEO\Dashboard\Infrastructure\Analytics_4

Site_Kit_Analytics_4_Adapter::get_period()privateYoast 1.0

Parses the response row and returns whether it's about the current period or the previous period.

Метод класса: Site_Kit_Analytics_4_Adapter{}

Хуков нет.

Возвращает

Строку. The key associated with the current or the previous period.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_period( $date_range_row ): string;
$date_range_row(Row) (обязательный)
The response row.

Заметки

Код Site_Kit_Analytics_4_Adapter::get_period() Yoast 25.0

private function get_period( Row $date_range_row ): string {
	foreach ( $date_range_row->getDimensionValues() as $dimension_value ) {
		if ( $dimension_value->getValue() === 'date_range_0' ) {
			return Comparison_Traffic_Data::CURRENT_PERIOD_KEY;
		}
		elseif ( $dimension_value->getValue() === 'date_range_1' ) {
			return Comparison_Traffic_Data::PREVIOUS_PERIOD_KEY;
		}
	}

	throw new Invalid_Request_Exception( 'Unexpected date range names' );
}