<?php

declare(strict_types=1);

$finderClass = class_exists('Isolated\\Symfony\\Component\\Finder\\Finder')
    ? 'Isolated\\Symfony\\Component\\Finder\\Finder'
    : 'Symfony\\Component\\Finder\\Finder';

$finder = $finderClass::create()
    ->files()
    ->ignoreVCS(true)
    ->notName('/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock/')
    ->exclude([
        'bin',
        'doc',
        'docs',
        'test',
        'Test',
        'tests',
        'Tests',
        'vendor-bin',
    ])
    ->in('vendor');

return [
    'prefix' => 'JCOGSDesign\\Dependency\\JcogsImgPro',
    'finders' => [
        $finder,
    ],
    'patchers' => [
        static function (string $filePath, string $prefix, string $content): string {
            if ($filePath === __DIR__ . '/vendor/aws/aws-sdk-php/src/Signature/SignatureV4.php') {
                return str_replace(
                    "const ISO8601_BASIC = '" . $prefix . '\\\\',
                    "const ISO8601_BASIC = '",
                    $content
                );
            }

            if ($filePath === __DIR__ . '/vendor/aws/aws-sdk-php/src/functions.php') {
                return str_replace(
                    "defined('\\\\GuzzleHttp\\\\ClientInterface::",
                    "defined('" . addslashes('\\\\' . $prefix) . "\\\\GuzzleHttp\\\\ClientInterface::",
                    $content
                );
            }

            return $content;
        },
    ],
];
