Automattic\WooCommerce\Admin\RemoteSpecs

DataSourcePoller::validate_spec()protectedWC 1.0

Validate the spec.

Method of the class: DataSourcePoller{}

No Hooks.

Return

true|false. The result of the validation.

Usage

// protected - for code of main (parent) or child class
$result = $this->validate_spec( $spec, $url );
$spec(object) (required)
The spec to validate.
$url(string) (required)
The url of the feed that provided the spec.

DataSourcePoller::validate_spec() code WC 9.7.1

protected function validate_spec( $spec, $url ) {
	$logger         = self::get_logger();
	$logger_context = array( 'source' => $url );

	if ( ! $this->get_spec_key( $spec ) ) {
		$logger->error(
			'Spec is invalid because the id is missing in feed',
			$logger_context
		);
		// phpcs:ignore
		$logger->error( print_r( $spec, true ), $logger_context );

		return false;
	}

	return true;
}