<?php

/*
 * This file is part of the Higidi/T3ExtCLI package.
 *
 * (c) Daniel Hürtgen <daniel@higidi.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace T3ExtCli\Utility;

/**
 * Class EnvironmentUtility.
 *
 * @author Daniel Hürtgen <daniel@higidi.de>
 */
class EnvironmentUtility
{

    /**
     * Determine the current home directory by the given environment vars.
     *
     * @return null|string Null or the path of the home directory.
     */
    public static function determineHomeDirectory()
    {
        if (defined('PHP_WINDOWS_VERSION_MAJOR') && static::getEnvironmentVariable('APPDATA')) {
            return strtr(static::getEnvironmentVariable('APPDATA'), '\\', '/');
        } else {
            if (static::getEnvironmentVariable('HOME')) {
                return rtrim(static::getEnvironmentVariable('HOME'), '/');
            }
        }

        return null;
    }

    /**
     * Gets an environment variable value.
     * (Wrapper method for optimal unit testing)
     *
     * @param string $name The environment varialbe name.
     * @return string The value of the environment variable.
     * @codeCoverageIgnore
     */
    protected static function getEnvironmentVariable($name)
    {
        return getenv($name);
    }

}

<?php

/*
 * This file is part of the Higidi/T3ExtCLI package.
 *
 * (c) Daniel Hürtgen <daniel@higidi.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace T3ExtCli\Utility;

/**
 * Class EnvironmentUtility.
 *
 * @author Daniel Hürtgen <daniel@higidi.de>
 */
class EnvironmentUtility
{

    /**
     * Determine the current home directory by the given environment vars.
     *
     * @return null|string Null or the path of the home directory.
     */
    public static function determineHomeDirectory()
    {
        if (defined('PHP_WINDOWS_VERSION_MAJOR') && getEnv('APPDATA')) {
            return strtr(getenv('APPDATA'), '\\', '/');
        } else {
            if (getenv('HOME')) {
                return rtrim(getenv('HOME'), '/');
            }
        }

        return null;
    }

}

Revert "[TASK] outsourced native getenv call to wrapper method (for unit testing)"
Revert "[TASK] outsourced native getenv call to wrapper method (for unit testing)"

This reverts commit 184d0ffa6f5fa4a980a0c6195570dba8fe6f374a.

Currently static method calls a hard to test and if conditions against environment
vars too. Switched back.
