<?php

declare(strict_types=1);

/**
 * Removes Windows-only HEIC converter artifacts on non-Windows hosts.
 *
 * This script is intended for Composer post-install and post-update hooks.
 */

$isWindows = false;

if (defined('PHP_OS_FAMILY')) {
    $isWindows = (PHP_OS_FAMILY === 'Windows');
} else {
    $isWindows = (stripos(PHP_OS, 'WIN') === 0);
}

if ($isWindows) {
    exit(0);
}

$root = dirname(__DIR__);

$filesToRemove = [
    $root . '/vendor/maestroerror/php-heic-to-jpg/bin/heicToJpg.exe',
    $root . '/vendor/maestroerror/php-heic-to-jpg/bin/php-heic-to-jpg-windows.zip',
    $root . '/vendor/bin/heicToJpgWin',
    $root . '/vendor/bin/heif-converter-windows',
];

foreach ($filesToRemove as $filePath) {
    if (is_file($filePath)) {
        @unlink($filePath);
    }
}
