2014-09-22 16:47:48 -04:00
|
|
|
<?php
|
|
|
|
|
2014-09-22 22:38:32 -04:00
|
|
|
namespace Amp;
|
2014-09-22 16:47:48 -04:00
|
|
|
|
|
|
|
/**
|
2015-03-19 11:14:21 -04:00
|
|
|
* Represents a failed computation resolution
|
2014-09-22 16:47:48 -04:00
|
|
|
*/
|
|
|
|
class Failure implements Promise {
|
|
|
|
private $error;
|
|
|
|
|
|
|
|
public function __construct(\Exception $error) {
|
|
|
|
$this->error = $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-03-23 11:07:40 -04:00
|
|
|
* {@inheritDoc}
|
2014-09-22 16:47:48 -04:00
|
|
|
*/
|
2015-05-19 18:49:08 -04:00
|
|
|
public function when(callable $func, $data = null) {
|
|
|
|
$func($this->error, $result = null, $data);
|
2014-09-22 16:47:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-03-23 11:07:40 -04:00
|
|
|
* {@inheritDoc}
|
2014-09-22 16:47:48 -04:00
|
|
|
*/
|
2015-05-19 18:49:08 -04:00
|
|
|
public function watch(callable $func, $data = null) {
|
2014-09-22 16:47:48 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|