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

Better name for testing safe mode and strict mode state

Add a nice named constructor
This commit is contained in:
Aidan Woods 2019-01-22 21:19:26 +00:00
parent bb424e606f
commit 3d41f270c2
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
9 changed files with 22 additions and 8 deletions

View File

@ -25,6 +25,8 @@
<referencedMethod name="Erusev\Parsedown\State::get" />
<referencedMethod name="Erusev\Parsedown\Parsedown::line" />
<referencedMethod name="Erusev\Parsedown\Parsing\Lines::last" />
<referencedMethod name="Erusev\Parsedown\Configurables\StrictMode::enabled" />
<referencedMethod name="Erusev\Parsedown\Configurables\SafeMode::enabled" />
</errorLevel>
</PossiblyUnusedMethod>
</issueHandlers>

View File

@ -78,7 +78,7 @@ final class Comment implements ContinuableBlock
return new Handler(
/** @return Text|RawHtml */
function (State $State) {
if ($State->getOrDefault(SafeMode::class)->enabled()) {
if ($State->getOrDefault(SafeMode::class)->isEnabled()) {
return new Text($this->html);
} else {
return new RawHtml($this->html);

View File

@ -56,7 +56,7 @@ final class Header implements Block
$StrictMode = $State->getOrDefault(StrictMode::class);
if ($StrictMode->enabled() && isset($text[0]) and $text[0] !== ' ') {
if ($StrictMode->isEnabled() && isset($text[0]) and $text[0] !== ' ') {
return null;
}

View File

@ -78,7 +78,7 @@ final class Markup implements ContinuableBlock
function (State $State) {
$SafeMode = $State->getOrDefault(SafeMode::class);
if ($SafeMode->enabled()) {
if ($SafeMode->isEnabled()) {
return new Element('p', [], [new Text($this->html)]);
} else {
return new RawHtml($this->html);

View File

@ -83,7 +83,7 @@ final class Image implements Inline
$attributes['title'] = $title;
}
if ($State->getOrDefault(SafeMode::class)->enabled()) {
if ($State->getOrDefault(SafeMode::class)->isEnabled()) {
$attributes['src'] = Element::filterUnsafeUrl($attributes['src']);
}

View File

@ -122,7 +122,7 @@ final class Link implements Inline
$attributes['title'] = $this->title;
}
if ($State->getOrDefault(SafeMode::class)->enabled()) {
if ($State->getOrDefault(SafeMode::class)->isEnabled()) {
$attributes['href'] = Element::filterUnsafeUrl($attributes['href']);
}

View File

@ -66,7 +66,7 @@ final class Markup implements Inline
function (State $State) {
$SafeMode = $State->getOrDefault(SafeMode::class);
if ($SafeMode->enabled()) {
if ($SafeMode->isEnabled()) {
return new Text($this->html);
} else {
return new RawHtml($this->html);

View File

@ -18,11 +18,17 @@ final class SafeMode implements Configurable
}
/** @return bool */
public function enabled()
public function isEnabled()
{
return $this->enabled;
}
/** @return self */
public static function enabled()
{
return new self(true);
}
/** @return self */
public static function initial()
{

View File

@ -18,11 +18,17 @@ final class StrictMode implements Configurable
}
/** @return bool */
public function enabled()
public function isEnabled()
{
return $this->enabled;
}
/** @return self */
public static function enabled()
{
return new self(true);
}
/** @return self */
public static function initial()
{