1
0
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:
Aidan Woods 2019-01-30 19:53:49 +00:00
parent 4dee1e9a55
commit c49d40027f
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
3 changed files with 22 additions and 3 deletions

View File

@ -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();
}
/**

View File

@ -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
View File

@ -0,0 +1,11 @@
<?php
namespace Erusev\Parsedown;
interface StateBearer
{
/**
* @return State
*/
public function state();
}