#!/usr/bin/env php
<?php

/**
 * @author    andrey-tech
 * @copyright 2023 andrey-tech
 * @link      https://github.com/andrey-tech/
 * @license   MIT
 */

declare(strict_types=1);

use AndreyTech\Pdepend\Summary\Formatter\Application;

(static function() {
    foreach ([ '/../../../', '/../vendor/' ] as $path) {
        $autoloadFile = __DIR__ . $path . 'autoload.php';
        if (is_file($autoloadFile)) {
            if (is_readable($autoloadFile)) {
                require_once $autoloadFile;
                return;
            }
            trigger_error('Can not read Composer file "autoload.php"', E_USER_ERROR);
        }
    }
    trigger_error('Can not find Composer file "autoload.php"', E_USER_ERROR);
})();

(new class
{
    public function __invoke(): void
    {
        $application = new Application();
        $exitCode = $application->run();
        exit($exitCode);
    }
})();
