1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Put reused code in a trait so boolean configurables are easy to make

This commit is contained in:
Aidan Woods 2019-01-25 21:18:33 +00:00
parent 8fe93f30ac
commit fce09a702a
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
3 changed files with 37 additions and 56 deletions

View File

@ -0,0 +1,35 @@
<?php
namespace Erusev\Parsedown\Configurables;
trait BooleanConfigurable
{
/** @var bool */
private $enabled = false;
/**
* @param bool $enabled
*/
public function __construct($enabled)
{
$this->enabled = $enabled;
}
/** @return bool */
public function isEnabled()
{
return $this->enabled;
}
/** @return static */
public static function enabled()
{
return new self(true);
}
/** @return static */
public static function initial()
{
return new self(false);
}
}

View File

@ -6,32 +6,5 @@ use Erusev\Parsedown\Configurable;
final class SafeMode implements Configurable
{
/** @var bool */
private $enabled = false;
/**
* @param bool $enabled
*/
public function __construct($enabled)
{
$this->enabled = $enabled;
}
/** @return bool */
public function isEnabled()
{
return $this->enabled;
}
/** @return self */
public static function enabled()
{
return new self(true);
}
/** @return self */
public static function initial()
{
return new self(false);
}
use BooleanConfigurable;
}

View File

@ -6,32 +6,5 @@ use Erusev\Parsedown\Configurable;
final class StrictMode implements Configurable
{
/** @var bool */
private $enabled = false;
/**
* @param bool $enabled
*/
public function __construct($enabled)
{
$this->enabled = $enabled;
}
/** @return bool */
public function isEnabled()
{
return $this->enabled;
}
/** @return self */
public static function enabled()
{
return new self(true);
}
/** @return self */
public static function initial()
{
return new self(false);
}
use BooleanConfigurable;
}