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:
parent
bb424e606f
commit
3d41f270c2
@ -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>
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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']);
|
||||
}
|
||||
|
||||
|
@ -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']);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user