mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
StateBearer must be constructable from State
This commit is contained in:
parent
4af22ec41a
commit
421a2393d0
@ -107,6 +107,12 @@ final class State implements StateBearer
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return self */
|
||||||
|
public static function fromState(State $State)
|
||||||
|
{
|
||||||
|
return $State;
|
||||||
|
}
|
||||||
|
|
||||||
public function isolatedCopy(): self
|
public function isolatedCopy(): self
|
||||||
{
|
{
|
||||||
return new self(\array_map(
|
return new self(\array_map(
|
||||||
|
@ -5,4 +5,6 @@ namespace Erusev\Parsedown;
|
|||||||
interface StateBearer
|
interface StateBearer
|
||||||
{
|
{
|
||||||
public function state(): State;
|
public function state(): State;
|
||||||
|
/** @return static */
|
||||||
|
public static function fromState(State $State);
|
||||||
}
|
}
|
||||||
|
@ -39,4 +39,16 @@ final class StateTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->assertInstanceOf(State::class, clone(new State));
|
$this->assertInstanceOf(State::class, clone(new State));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
* @throws \PHPUnit\Framework\Exception
|
||||||
|
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testStateFromStateIdentical()
|
||||||
|
{
|
||||||
|
$State = new State;
|
||||||
|
|
||||||
|
$this->assertSame($State, State::fromState($State));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user