<?php
namespace WPEventGenius\Common\Registration\Field;

use WPEventGenius\Common\Registration\Submission\Validator;

if ( ! defined( 'ABSPATH' ) ) {
	exit; 
}

class RadioType extends BaseFieldType {
	public function get_type() {
		return 'radio';
	}

	public function get_value( $registration_data = array() ) {
		$slug = $this->get_slug();
		if ( ! array_key_exists( $slug, $registration_data ) ) {
			return $this->value;
		}
		$stored = $registration_data[ $slug ];
		if ( Validator::is_absent_submission_value( $stored ) ) {
			return $this->value;
		}
		if ( is_array( $stored ) ) {
			return $stored[0];
		}
		return $stored;
	}
}