<?php
/**
 * Turns stored tokens into words a person reads.
 *
 * @package SkyServers\Retragere
 */

declare(strict_types=1);

namespace SkyServers\Retragere\Wp;

use SkyServers\Retragere\Core\WithdrawalRequest;

/**
 * The register is evidence. It gets read by a shop owner under pressure and, on
 * a bad day, by an inspector - neither of whom should have to work out that
 * "ss_noua" means the request is untouched, or that "none" is how this plugin
 * spells "no". Storage keeps its tokens; anything shown or exported goes
 * through here.
 */
final class Labels
{
    public static function status(string $status): string
    {
        $labels = PostType::statusLabels();

        return $labels[$status] ?? $status;
    }

    public static function type(string $type): string
    {
        $labels = [
            WithdrawalRequest::TYPE_LIBERA   => __('Free-form declaration', 'skyservers-retragere-contract'),
            WithdrawalRequest::TYPE_PARTIALA => __('Partial withdrawal', 'skyservers-retragere-contract'),
            WithdrawalRequest::TYPE_TOTALA   => __('Full withdrawal', 'skyservers-retragere-contract'),
        ];

        return $labels[$type] ?? $type;
    }

    /**
     * Which signal identified the order stays in the request detail for
     * diagnosis; the register only needs the answer.
     */
    public static function b2b(string $signal): string
    {
        if ('' === $signal || 'none' === $signal) {
            return __('No', 'skyservers-retragere-contract');
        }

        return __('Yes', 'skyservers-retragere-contract');
    }
}
