<?php

declare(strict_types=1);

ini_set('display_errors', '1');
error_reporting(E_ALL);

$app = require dirname(__DIR__) . '/bootstrap/app.php';

echo '<pre>';

echo "ROUTES_PATH:\n";
echo ROUTES_PATH . "\n\n";

$webFile = ROUTES_PATH . '/web.php';

echo "WEB FILE:\n";
echo $webFile . "\n\n";

echo "FILE EXISTS:\n";
var_dump(file_exists($webFile));

echo "\nLAST MODIFIED:\n";

if (file_exists($webFile)) {
    echo date(
        'Y-m-d H:i:s',
        filemtime($webFile)
    );
}

echo "\n\nPOSITION TEXT EXISTS IN ACTIVE WEB.PHP:\n";

if (file_exists($webFile)) {

    $content = file_get_contents($webFile);

    var_dump(
        str_contains(
            $content,
            "'/positions'"
        )
    );
}

echo "\n\nACTIVE WEB.PHP POSITION LINES:\n";

if (file_exists($webFile)) {

    $lines = file(
        $webFile
    );

    foreach ($lines as $number => $line) {

        if (
            stripos(
                $line,
                'position'
            ) !== false
        ) {
            echo ($number + 1)
                . ': '
                . htmlspecialchars($line);
        }
    }
}

echo '</pre>';