<?php
/**
 * SectionType class.
 *
 * Defines available widget positions for the PowerWidget module.
 *
 * @package Ilabs\Firevert\Modules\PowerWidget\Services\Type
 */

declare( strict_types=1 );

namespace Ilabs\Firevert\Modules\PowerWidget\Services\Type;

/**
 * Class SectionType.
 */
final class PositionType {

	public const BOTTOM_RIGHT = 'bottom_right';
	public const BOTTOM_LEFT  = 'bottom_left';

	/**
	 * Returns all available section slugs => labels.
	 *
	 * @return array<string, string>
	 */
	public static function get_all(): array {
		return array(
			self::BOTTOM_RIGHT => __( 'Bottom right corner of the screen', 'firevert' ),
			self::BOTTOM_LEFT  => __( 'Bottom left corner of the screen', 'firevert' ),
		);
	}

	/**
	 * Returns true if the position exists.
	 *
	 * @param string $position Position value.
	 *
	 * @return bool
	 */
	public static function exists( string $position ): bool {
		return array_key_exists( $position, self::get_all() );
	}

	/**
	 * Returns label for a given widget position.
	 *
	 * @param string $position Section slug.
	 *
	 * @return string|null
	 */
	public static function get_label( string $position ): ?string {
		$all = self::get_all();

		return $all[ $position ] ?? null;
	}
}
