<?php

declare(strict_types=1);

namespace App\Enums;

enum FeeType: string
{
    case SellerCommission = 'seller_commission';
    case BuyerFee = 'buyer_fee';
    case TransferFee = 'transfer_fee';
    case ListingFee = 'listing_fee';
    case FeaturedFee = 'featured_fee';
    case PayoutFee = 'payout_fee';
    case Tax = 'tax';

    /** Fees the buyer pays on top of the sale price. */
    public function isChargedToBuyer(): bool
    {
        return in_array($this, [self::BuyerFee, self::TransferFee, self::Tax], true);
    }

    /** Fees deducted from the seller's gross proceeds. */
    public function isDeductedFromSeller(): bool
    {
        return in_array($this, [
            self::SellerCommission,
            self::ListingFee,
            self::FeaturedFee,
            self::PayoutFee,
        ], true);
    }

    public function label(): string
    {
        return match ($this) {
            self::SellerCommission => 'Marketplace commission',
            self::BuyerFee => 'Marketplace fee',
            self::TransferFee => 'Domain transfer fee',
            self::ListingFee => 'Listing fee',
            self::FeaturedFee => 'Featured placement fee',
            self::PayoutFee => 'Payout fee',
            self::Tax => 'Tax',
        };
    }
}
