<?php

$modules_dir = "Modules";
$suffix = "-module";
$pending = scandir($modules_dir);


foreach ($pending as $p) :
    str_contains($p, $suffix) ? Install($p) : false;
endforeach;

function Install($p)
{
    global $modules_dir;
    global $suffix;
    $s = str_replace($suffix, '', $p);
    $s = ucfirst($s);
    echo "Instalando módulo $s..." . PHP_EOL;
    if (rename($modules_dir . '/' . $p, $modules_dir . '/' . $s)) {
        echo "Módulo $s instalado!" . PHP_EOL;
    } else {
        echo "Ocorreu um erro ao instalar $s";
    }
}
