mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Add StateBearer which can carry state
This commit is contained in:
parent
4dee1e9a55
commit
c49d40027f
@ -25,9 +25,9 @@ final class Parsedown
|
||||
/** @var State */
|
||||
private $State;
|
||||
|
||||
public function __construct(State $State = null)
|
||||
public function __construct(StateBearer $StateBearer = null)
|
||||
{
|
||||
$this->State = $State ?: new State;
|
||||
$this->State = ($StateBearer ?: new State)->state();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@ namespace Erusev\Parsedown;
|
||||
use Erusev\Parsedown\AST\StateRenderable;
|
||||
use Erusev\Parsedown\Html\Renderable;
|
||||
|
||||
final class State
|
||||
final class State implements StateBearer
|
||||
{
|
||||
/**
|
||||
* @var array<class-string<Configurable>, Configurable>
|
||||
@ -88,4 +88,12 @@ final class State
|
||||
$StateRenderables
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return State
|
||||
*/
|
||||
public function state()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
11
src/StateBearer.php
Normal file
11
src/StateBearer.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Erusev\Parsedown;
|
||||
|
||||
interface StateBearer
|
||||
{
|
||||
/**
|
||||
* @return State
|
||||
*/
|
||||
public function state();
|
||||
}
|
Loading…
Reference in New Issue
Block a user