<?php
/**
 * BookiFlex Core
 *
 * @package    BookiFlex
 * @subpackage Core
 * @author     BookiFlex
 * @copyright  Copyright (c) 2025 BookiFlex
 * @license    GPL-2.0-or-later
 *
 * @link       https://bookiflex.com
 */


declare(strict_types=1);
namespace BookiFlex\Core\ValueObject;

defined( 'ABSPATH' ) || exit;

/**
 * Represents a placement location type
 */
final class PlacementLocation
{
    private const MAIN = 'main';
    private const EXTRA = 'extra';
    private const WITHOUT = 'without';

    private string $value;

    private function __construct(string $value)
    {
        if (!in_array($value, [self::MAIN, self::EXTRA, self::WITHOUT], true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Invalid placement location: %s',
                    $value
                )
            );
        }
        $this->value = $value;
    }

    public static function main(): self
    {
        return new self(self::MAIN);
    }

    public static function extra(): self
    {
        return new self(self::EXTRA);
    }

    public static function without(): self
    {
        return new self(self::WITHOUT);
    }

    public function isMain(): bool
    {
        return $this->value === self::MAIN;
    }

    public function isExtra(): bool
    {
        return $this->value === self::EXTRA;
    }

    public function isWithout(): bool
    {
        return $this->value === self::WITHOUT;
    }

    public function toString(): string
    {
        return $this->value;
    }

    public function equals(PlacementLocation $other): bool
    {
        return $this->value === $other->value;
    }
}
