Automattic\WooCommerce\Internal\Api\Autogenerated\GraphQLTypes\Scalars

DateTime::getpublic staticWC 1.0

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$result = DateTime::get(): CustomScalarType;

Код DateTime::get() WC 11.1.1

public static function get(): CustomScalarType {
	if ( null === self::$instance ) {
		self::$instance = new CustomScalarType(
			array(
				'name'         => 'DateTime',
				'description'  => __( 'An ISO 8601 encoded date and time string.', 'woocommerce' ),
				'serialize'    => fn( $value ) => DateTimeScalar::serialize( $value ),
				'parseValue'   => function ( $value ) {
					try {
						return DateTimeScalar::parse( $value );
					} catch ( \InvalidArgumentException $e ) {
						throw new \Automattic\WooCommerce\Api\Infrastructure\Schema\Error( $e->getMessage() );
					}
				},
				'parseLiteral' => function ( $value_node, ?array $variables = null ) {
					if ( $value_node instanceof \Automattic\WooCommerce\Api\Infrastructure\Schema\AST\StringValueNode ) {
						try {
							return DateTimeScalar::parse( $value_node->value );
						} catch ( \InvalidArgumentException $e ) {
							throw new \Automattic\WooCommerce\Api\Infrastructure\Schema\Error( $e->getMessage() );
						}
					}
					throw new \Automattic\WooCommerce\Api\Infrastructure\Schema\Error(
						'DateTime must be a string, got: ' . $value_node->kind
					);
				},
			)
		);
	}
	return self::$instance;
}