Ejemplo n.º 1
0
	,				\shell_exec('java -version 2>&1'),
					$matches
				)){
					return \intval($matches['version']);
				} else {
					return 0;
				}
			});

		static::$isWindows =
			Operators::lazy(static function(){
				return (new \Yasca\Core\FunctionPipe)
				->wrap(PHP_OS)
				->pipe('\substr', 0, \strlen('win'))
				->pipe('\strcasecmp', 'win')
				->pipe([Operators::_class, 'equals'], 0)
				->unwrap();
			});

		//TODO: Update with more values where PHP_OS !== 'Linux', but are Linux systems
		static::$isLinux = Operators::identity(PHP_OS === 'Linux');

		static::$isLinuxWithWine =
			Operators::lazy(static function(){
				return static::isLinux() &&
						!preg_match('/no wine in/', \shell_exec('which wine'));
			});
	},
	null,
	__NAMESPACE__ . '\\' . \basename(__FILE__, '.php')
)->__invoke();
Ejemplo n.º 2
0
 public function continueWith(callable $asyncFactory)
 {
     if ($this->isDone() === true) {
         return $asyncFactory($this);
     }
     $getAsync = Operators::lazy(function () use($asyncFactory) {
         $async = $asyncFactory($this);
         while ($async instanceof Wrapper) {
             $async = $async->unwrap();
         }
         if (!$async instanceof Async) {
             throw new \UnexpectedValueException('Continuation factory did not return an Async');
         }
         return $async;
     });
     return new self(function () use($getAsync) {
         return $this->isDone() === true && $getAsync()->isDone() === true;
     }, function () use($getAsync) {
         return $getAsync()->result();
     });
 }