<?php
/**
 * PageUrlBuilder class.
 *
 * Builds admin URLs for Firevert pages and tabs.
 *
 * @package Ilabs\Firevert\Core\Services\Builder
 */

declare( strict_types=1 );

namespace Ilabs\Firevert\Core\Services\Builder;

/**
 * PageUrlBuilder class.
 */
final class PageUrlBuilder {

	/**
	 * Returns base Firevert admin page.
	 *
	 * @return string
	 */
	public function base(): string {
		return admin_url( 'admin.php' );
	}

	/**
	 * Returns URL to a tabless base Firevert page.
	 *
	 * @return string
	 */
	public function default(): string {
		return add_query_arg( 'page', 'firevert', $this->base() );
	}

	/**
	 * Returns URL to the "General" settings tab.
	 *
	 * @return string
	 */
	public function general(): string {
		return add_query_arg(
			array(
				'page' => 'firevert',
				'tab'  => 'general',
			),
			$this->base()
		);
	}

	/**
	 * Returns URL to the "Modules" tab.
	 *
	 * @return string
	 */
	public function modules(): string {
		return add_query_arg(
			array(
				'page' => 'firevert',
				'tab'  => 'modules',
			),
			$this->base()
		);
	}

	/**
	 * Returns URL to a specific module's settings.
	 *
	 * @param string $slug Module slug.
	 *
	 * @return string
	 */
	public function module( string $slug ): string {
		return add_query_arg(
			array(
				'page'   => 'firevert',
				'tab'    => 'modules',
				'module' => $slug,
			),
			$this->base()
		);
	}
}
