<?php

namespace SugarCalendarBookings\Support\Ajax;

/**
 * AJAX route registry.
 *
 * @since 1.0.0
 */
class RouteRegistry {

	/**
	 * The routes.
	 *
	 * @since 1.0.0
	 *
	 * @var Route[]
	 */
	private $routes = [];

	/**
	 * Get the routes.
	 *
	 * @since 1.0.0
	 *
	 * @return Route[]
	 */
	public function get_routes() {

		return $this->routes;
	}

	/**
	 * Register a route.
	 *
	 * @since 1.0.0
	 *
	 * @param string                      $task     The task.
	 * @param array{0: object, 1: string} $callback The callback.
	 *
	 * @return Route
	 */
	public function route( $task, $callback ) {

		$route = new Route( $task, $callback );

		$this->routes[] = $route;

		return $route;
	}
}
