summaryrefslogtreecommitdiff
path: root/includes/deferred/CallableUpdate.php
blob: 808626d0f9b5c7557e0395c9a31ae25665a79dd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

/**
 * Deferrable Update for closure/callback
 */
class MWCallableUpdate implements DeferrableUpdate {
	/**
	 * @var Closure|callable
	 */
	private $callback;

	/**
	 * @param callable $callback
	 * @throws MWException
	 */
	public function __construct( $callback ) {
		if ( !is_callable( $callback ) ) {
			throw new MWException( 'Not a valid callback/closure!' );
		}
		$this->callback = $callback;
	}

	/**
	 * Run the update
	 */
	public function doUpdate() {
		call_user_func( $this->callback );
	}
}