ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
LazyIntercept.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 use Closure;
26 
27 final class LazyIntercept implements Intercept
28 {
31 
35  public function __construct(Closure $create_intercept)
36  {
37  $this->intercept = function () use ($create_intercept): Intercept {
38  $intercept = $create_intercept();
39  $this->intercept = static fn(): Intercept => $intercept;
40  return $intercept;
41  };
42  }
43 
44  public function intercept(): bool
45  {
46  return ($this->intercept)()->intercept();
47  }
48 
49  public function id(): string
50  {
51  return ($this->intercept)()->id();
52  }
53 
54  public function target(): Target
55  {
56  return ($this->intercept)()->target();
57  }
58 }