# wp-optimize/3.2.22/vendor/rosell-dk/exec-with-fallback/src/Availability.php

WP-Optimize – Cache, Compress images, Minify &amp; Clean database to boost page speed &amp; performance, version 3.2.22. 40 lines.

- Page: https://pluginprobe.com/plugins/wp-optimize/3.2.22/code/vendor/rosell-dk/exec-with-fallback/src/Availability.php
- Raw: https://pluginprobe.com/plugins/wp-optimize/3.2.22/raw/vendor/rosell-dk/exec-with-fallback/src/Availability.php
- Modified: 2022-01-25T13:38:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-optimize/3.2.22/code/vendor/rosell-dk/exec-with-fallback/src/Availability.php#L10-L20`.

```php
<?php
namespace ExecWithFallback;

/**
 * Check if any of the methods are available on the system.
 *
 * @package    ExecWithFallback
 * @author     Bjørn Rosell <it@rosell.dk>
 */
class Availability extends ExecWithFallback
{

    /**
     * Check if any of the methods are available on the system.
     *
     * @param boolean $needResultCode  Whether the code using this library is going to supply $result_code to the exec
     *         call. This matters because shell_exec is only available when not.
     */
    public static function anyAvailable($needResultCode = true)
    {
        foreach (self::$methods as $method) {
            if (self::methodAvailable($method, $needResultCode)) {
                return true;
            }
        }
        return false;
    }

    public static function methodAvailable($method, $needResultCode = true)
    {
        if (!ExecWithFallback::functionEnabled($method)) {
            return false;
        }
        if ($needResultCode) {
            return ($method != 'shell_exec');
        }
        return true;
    }
}

```
