<?php

/**
 * This file contains QUI\NodeJs\Environment
 */

namespace QUI\NodeJs;

/**
 * Class Environment
 *
 * @package QUI\NodeJs
 */
class Environment
{
    /**
     * True if OS is Windows
     *
     * @return bool
     */
    public static function isWindows()
    {
        return defined('PHP_WINDOWS_VERSION_BUILD');
    }

    /**
     * True if OS is Linux
     *
     * @return bool
     */
    public static function isLinux()
    {
        return PHP_OS === 'Linux';
    }

    /**
     * True if processor is Arm
     *
     * @return bool
     */
    public static function isArm()
    {
        return strpos(strtolower(php_uname("m")), "arm") === 0;
    }

    /**
     * True if processor is Armv7l
     *
     * @return bool
     */
    public static function isArmV7l()
    {
        return php_uname("m") === 'armv7l';
    }

    /**
     * True if processor is Armv6l
     *
     * @return bool
     */
    public static function isArmV6l()
    {
        return php_uname("m") === 'armv6l';
    }

    /**
     * Returns 32 or 64 depending on supported architecture
     *
     * @return int
     */
    public static function getArchitecture()
    {
        return 8 * PHP_INT_SIZE;
    }

    /**
     * Returns true if the system is a 64bit system
     *
     * @return int
     */
    public static function is64Bit()
    {
        return self::getArchitecture() === 64;
    }

    /**
     * Returns true if the system is a 32bit system
     *
     * @return int
     */
    public static function is32Bit()
    {
        return self::getArchitecture() === 32;
    }
}
