/** * create a timeout value by looking at a default timeout and an * optional override value * * @param int|float|null $defaultTimeout * what is the default timeout to use? * @param int|float|null $overrideTimeout * what override value do we want to use? * @return float|null * NULL if there is no timeout * a float otherwise */ public static function from($defaultTimeout, $overrideTimeout = null) { // robustness! RequireTimeoutOrNull::check($defaultTimeout); RequireTimeoutOrNull::check($overrideTimeout); return self::fromNumeric($defaultTimeout, $overrideTimeout); }
/** * create a timeout value by looking at a default timeout and an * optional override value * * @param int|float|null $defaultTimeout * what is the default timeout to use? * @param int|float|null $overrideTimeout * what override value do we want to use? * @return int|null * NULL if there is no timeout * a float otherwise */ public static function from($defaultTimeout, $overrideTimeout = null) { // robustness! RequireTimeoutOrNull::check($defaultTimeout); RequireTimeoutOrNull::check($overrideTimeout); $retval = $overrideTimeout === null ? $defaultTimeout : $overrideTimeout; if ($retval === null) { return $retval; } return intval($retval); }
/** * @covers ::check * @dataProvider provideNonTimeoutNorNulls * @expectedException GanbaroDigital\DateTime\Exceptions\E4xx_UnsupportedType */ public function testRejectsNonTimeoutsWhenCalledStatically($item) { // ---------------------------------------------------------------- // setup your test // ---------------------------------------------------------------- // perform the change RequireTimeoutOrNull::check($item); }
/** * run a CLI command using the popen() interface * * @param array|Traversable $command * the command to execute * @param int|null $timeout * how long before we force the command to close? * @param string|null $cwd * the folder to run the command inside * @param EventStream $eventStream * helper to send events to * @return ProcessResult * the result of executing the command */ public static function run($command, $timeout = null, $cwd = null, EventStream $eventStream = null) { // robustness RequireTraversable::checkMixed($command, E4xx_UnsupportedType::class); RequireTimeoutOrNull::check($timeout); RequireAbsoluteFolderOrNull::check($cwd); $eventStream = GuaranteeEventStream::from($eventStream); return self::runCommand($command, $timeout, $cwd, $eventStream); }