| 1 | <?php |
||
| 10 | class CallbackProvider implements FormatterProvider |
||
| 11 | { |
||
| 12 | private \Closure |
||
|
|
|||
| 13 | $closure; |
||
| 14 | |||
| 15 | 3 | public function __construct(\Closure $closure) |
|
| 16 | { |
||
| 17 | 3 | $this->closure = $closure; |
|
| 18 | 3 | } |
|
| 19 | |||
| 20 | public function hasFormatter(?string $index): bool |
||
| 21 | { |
||
| 22 | return true; |
||
| 23 | } |
||
| 24 | |||
| 25 | 3 | public function getFormatter(?string $fileExtension, ?string $index = null): Formatter |
|
| 26 | { |
||
| 27 | 3 | $closure = $this->closure; |
|
| 28 | |||
| 29 | 3 | return $closure($fileExtension, $index); |
|
| 30 | } |
||
| 31 | } |
||
| 32 |