MediaWiki  master
DeferredStringifier.php
Go to the documentation of this file.
1 <?php
29  private $callback;
30 
32  private $params;
33 
35  private $result;
36 
41  public function __construct( $callback, ...$params ) {
42  $this->callback = $callback;
43  $this->params = $params;
44  }
45 
51  public function __toString() {
52  if ( $this->result === null ) {
53  $this->result = call_user_func_array( $this->callback, $this->params );
54  }
55  return $this->result;
56  }
57 }
DeferredStringifier\$callback
callable $callback
Callback used for result string generation.
Definition: DeferredStringifier.php:29
DeferredStringifier\$params
array $params
Definition: DeferredStringifier.php:32
DeferredStringifier
Definition: DeferredStringifier.php:27
DeferredStringifier\__construct
__construct( $callback,... $params)
Definition: DeferredStringifier.php:41
DeferredStringifier\$result
string $result
Definition: DeferredStringifier.php:35
DeferredStringifier\__toString
__toString()
Get the string generated from the callback.
Definition: DeferredStringifier.php:51