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

declare(strict_types=1);

namespace BookiFlex\Extensions\Onboarding\Api\Transformer;

use BookiFlex\Extensions\Onboarding\ValueObject\OnboardingResult;

defined( 'ABSPATH' ) || exit;

/**
 * Complete Response Transformer
 *
 * Transforms OnboardingResult to API response format.
 * Returns mode and next steps for frontend consumption.
 *
 * @package BookiFlex\Extensions\Onboarding\Api\Transformer
 * @since   1.0.0
 */
class CompleteResponseTransformer
{
    /**
     * Transform OnboardingResult to API response format
     *
     * @param  OnboardingResult $result Onboarding result
     * @return array{mode: string, nextSteps: array} Response array
     */
    public function transform(OnboardingResult $result): array
    {
        return [
            'mode' => $result->mode->value,
            'nextSteps' => array_map(
                fn($step) => $step->toArray(),
                $result->nextSteps
            ),
        ];
    }
}
