<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console;

final class ConsolePath
{
    public static function basePath(): string
    {
        /*
         * __DIR__ is:
         *   <project>/core/Platform/Console
         *
         * Correct project root is dirname(__DIR__, 3):
         *   1 => <project>/core/Platform
         *   2 => <project>/core
         *   3 => <project>
         *
         * Earlier dirname(__DIR__, 4) incorrectly resolved to the parent of
         * the PPphp project, causing console-only verification paths to scan
         * the wrong directory while smoke tests and tools passed.
         */
        $base = dirname(__DIR__, 3);
        $real = realpath($base);

        return $real !== false ? $real : $base;
    }
}
