#!/usr/bin/env php
<?php
use Environ\Platform;
use Environ\Runtime;

require dirname(__DIR__).'/vendor/autoload.php';

function printval($key, $value) {
    if (is_bool($value)) {
        $value = ($value ? 'yes' : 'no');
    }

    printf('%-20s : %s%s', $key, $value, PHP_EOL);
}

function main() {
    printf('-- Platform --%s', PHP_EOL);
    printval('Machine name', Platform::getMachineName());
    printval('Operating system', Platform::getOSName());
    printval('OS release', Platform::release());
    printval('OS version', Platform::version());
    printval('CPU architecture', Platform::getArch());
    printval('64-bit', Platform::is64Bit());
    printval('Number of processors', Platform::getCpuCount());

    if (!empty($distro = Platform::linuxDistribution())) {
        printf('%s-- Linux distribution --%1$s', PHP_EOL);

        foreach (Platform::linuxDistribution() as $key => $value) {
            printval($key, $value);
        }
    }

    printf('%s-- Runtime --%1$s', PHP_EOL);
    printval('Interpreter binary', Runtime::path());
    printval('Version', Runtime::version());
    printval('64-bit', Runtime::is64Bit());
    printval('HHVM', Runtime::isHHVM());
    printval('JPHP', Runtime::isJPHP());
    printval('Thread safe', Runtime::isThreadSafe());
    printval('Server module', Runtime::isServerModule());
}

main();
