kylekatarnls/multi-tester

View on GitHub
bin/multi-tester

Summary

Maintainability
Test Coverage
#!/usr/bin/env php
<?php

use MultiTester\MultiTester;

set_time_limit(-1);

function includeIfExists($file)
{
    if (file_exists($file)) {
        return include $file;
    }

    return false;
}

function getLoader()
{
    global $possibleFolders;

    foreach ($possibleFolders as $dir) {
        if ($loader = includeIfExists($dir . '/autoload.php')) {
            if (class_exists('MultiTester\MultiTester')) {
                return $loader;
            }

            $loader->unregister();
        }
    }

    return false;
}

$cwd = @getcwd() ?: '.';
$possibleFolders = array_unique(array_filter(array_map('realpath', [
    $cwd . '/vendor',
    __DIR__ . '/../vendor',
    __DIR__ . '/../../..'
]), 'file_exists'));

//Check for autoload file
if (!getLoader()) {
    echo "Composer's autoload.php not found in checked folders:\n - " . implode("\n - ", $possibleFolders) . "\n";
    exit(1);
}

exit((new MultiTester())->run($argv) ? 0 : 1);