LdapTools\Utilities\ADTimeSpan::getInstance PHP Метод

getInstance() публичный статический Метод

Get an instance of the class based on a specific time unit as the second parameter.
public static getInstance ( integer $value, string $unit )
$value integer The time value.
$unit string The time unit. One of the constants of this class: DAYS, HOURS, MINUTES, SECONDS.
    public static function getInstance($value, $unit)
    {
        if (!array_key_exists($unit, self::UNIT)) {
            throw new InvalidArgumentException('Time unit "%s" is not recognized.', $unit);
        }
        $setter = 'set' . ucfirst($unit);
        return (new self())->{$setter}($value);
    }