<?php
declare(strict_types=1);

namespace Ekesto\CacheInvalidator\Core\WooCommerce;

/**
 * Lite-safe no-op WooCommerce provider.
 */
final class NullWooCommerceIntegration implements WooCommerceIntegrationInterface
{
    /**
     * Determine whether WooCommerce implementation services are available.
     *
     * @return bool Always false for the null provider.
     */
    public function isAvailable(): bool
    {
        return false;
    }

    /**
     * Resolve the canonical permalink for the WooCommerce Shop page.
     *
     * @return string Always empty for the null provider.
     */
    public function getShopPageUrl(): string
    {
        return '';
    }

    /**
     * Resolve canonical baseline targets for a WooCommerce product update.
     *
     * @param \WP_Post $post Triggering post.
     * @return array{post_ids:int[],urls:string[],trusted_urls:string[]}
     */
    public function resolveProductBaseline(\WP_Post $post): array
    {
        unset($post);

        return $this->emptyBaselineResult();
    }

    /**
     * Return WooCommerce-specific taxonomy allowlist for archive resolution.
     *
     * @param string $postType Post type slug.
     * @return string[]|null Always null for the null provider.
     */
    public function getAllowedTaxonomiesForPostType(string $postType): ?array
    {
        unset($postType);

        return null;
    }

    /**
     * Resolve the parent product ID for a WooCommerce product variation change.
     *
     * @param int   $variationId Variation post ID.
     * @param mixed $variation   WooCommerce variation object when provided.
     * @return int Always 0 for the null provider.
     */
    public function resolveProductVariationParentId(int $variationId, $variation = null): int
    {
        unset($variationId, $variation);

        return 0;
    }

    /**
     * Return an empty baseline result with the full contract shape.
     *
     * @return array{post_ids:int[],urls:string[],trusted_urls:string[]}
     */
    private function emptyBaselineResult(): array
    {
        return [
            'post_ids' => [],
            'urls' => [],
            'trusted_urls' => [],
        ];
    }
}
