ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
LazyIntercept.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use Closure;
26
27final class LazyIntercept implements Intercept
28{
30 private Closure $intercept;
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}