Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / deferred / CallableUpdate.php
1 <?php
2
3 /**
4 * Deferrable Update for closure/callback
5 */
6 class MWCallableUpdate implements DeferrableUpdate {
7 /** @var Closure|callable */
8 private $callback;
9
10 /**
11 * @param callable $callback
12 * @throws InvalidArgumentException
13 */
14 public function __construct( $callback ) {
15 if ( !is_callable( $callback ) ) {
16 throw new InvalidArgumentException( 'Not a valid callback/closure!' );
17 }
18 $this->callback = $callback;
19 }
20
21 public function doUpdate() {
22 call_user_func( $this->callback );
23 }
24 }