<?php
declare(strict_types=1);

namespace WP_AUX\Enum;

use WP_AUX\Interfaces\OptionsEnumInterface;
use WP_AUX\Traits\EnumTraits;

enum SharePlatformsEnum: string implements OptionsEnumInterface
{
  use EnumTraits;

  case X = 'x';
  case Facebook = 'facebook';
  case LinkedIn = 'linkedin';
  case Email = 'email';

  public const SETTING_LABEL = 'AUX share platforms';

  public function label(): string
  {
    return match($this) {
      self::X => 'X',
      self::Facebook => 'Facebook',
      self::LinkedIn => 'LinkedIn',
      self::Email => 'Email',
    };
  }

  public function shareUrlFormat(): string
  {
    return match($this) {
      self::X => 'https://x.com/intent/post?url={url}',
      self::Facebook => 'https://www.facebook.com/share.php?u={url}',
      self::LinkedIn => 'https://www.linkedin.com/sharing/share-offsite/?url={url}',
      self::Email => 'mailto:?subject={title}&body={url}',
      default => '#',
    };
  }

  public function shareLabel(): string
  {
    switch ($this) {
      case self::Email:
        return 'Share via ' . $this->label();
      default:
        return 'Share on ' . $this->label();
    }
  }

  public function icon(): string
  {
    switch ($this) {
      case self::Email:
        return 'aux_envelope';
      case self::X:
        return 'aux_twitter';
      default:
        return 'aux_' . $this->value;
    }
  }
}
