mirror of
https://github.com/flarum/core.git
synced 2025-07-26 03:01:22 +02:00
* Extender docblocks cleanup * Excplicit type hinting in extenders * Bring method under constructor * Mark some classes and methods as internal * Remove beta references Co-authored-by: Clark Winkelmann <clark.winkelmann@gmail.com>
52 lines
894 B
PHP
52 lines
894 B
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Flarum.
|
|
*
|
|
* For detailed copyright and license information, please view the
|
|
* LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Flarum\Frontend\Compiler\Source;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
class StringSource implements SourceInterface
|
|
{
|
|
/**
|
|
* @var callable
|
|
*/
|
|
protected $callback;
|
|
|
|
private $content;
|
|
|
|
/**
|
|
* @param callable $callback
|
|
*/
|
|
public function __construct(callable $callback)
|
|
{
|
|
$this->callback = $callback;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getContent(): string
|
|
{
|
|
if (is_null($this->content)) {
|
|
$this->content = call_user_func($this->callback);
|
|
}
|
|
|
|
return $this->content;
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getCacheDifferentiator()
|
|
{
|
|
return $this->getContent();
|
|
}
|
|
}
|