Skip to content

Commit

Permalink
Merge pull request #1128 from HDInnovations/development
Browse files Browse the repository at this point in the history
(Refactor) Logical To Boolean
  • Loading branch information
HDVinnie authored Feb 12, 2020
2 parents d621095 + 336242a commit fffa67c
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions app/Helpers/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected function lines(array $lines)

$indent = 0;

while (isset($line[$indent]) and $line[$indent] === ' ') {
while (isset($line[$indent]) && $line[$indent] === ' ') {
$indent++;
}

Expand Down Expand Up @@ -231,7 +231,7 @@ protected function lines(array $lines)

// ~

if (isset($CurrentBlock) and !isset($CurrentBlock['type']) and !isset($CurrentBlock['interrupted'])) {
if (isset($CurrentBlock) && !isset($CurrentBlock['type']) && !isset($CurrentBlock['interrupted'])) {
$CurrentBlock['element']['text'] .= "\n".$text;
} else {
$Blocks[] = $CurrentBlock;
Expand All @@ -244,7 +244,7 @@ protected function lines(array $lines)

// ~

if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type'])) {
if (isset($CurrentBlock['continuable']) && $this->isBlockCompletable($CurrentBlock['type'])) {
$CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
}

Expand Down Expand Up @@ -289,7 +289,7 @@ protected function isBlockCompletable($Type)

protected function blockCode($Line, $Block = null)
{
if (isset($Block) and !isset($Block['type']) and !isset($Block['interrupted'])) {
if (isset($Block) && !isset($Block['type']) && !isset($Block['interrupted'])) {
return;
}

Expand Down Expand Up @@ -344,11 +344,11 @@ protected function blockCodeComplete($Block)

protected function blockComment($Line)
{
if ($this->markupEscaped or $this->safeMode) {
if ($this->markupEscaped || $this->safeMode) {
return;
}

if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!') {
if (isset($Line['text'][3]) && $Line['text'][3] === '-' && $Line['text'][2] === '-' && $Line['text'][1] === '!') {
$Block = [
'markup' => $Line['body'],
];
Expand Down Expand Up @@ -450,7 +450,7 @@ protected function blockHeader($Line)
if (isset($Line['text'][1])) {
$level = 1;

while (isset($Line['text'][$level]) and $Line['text'][$level] === '#') {
while (isset($Line['text'][$level]) && $Line['text'][$level] === '#') {
$level++;
}

Expand Down Expand Up @@ -513,7 +513,7 @@ protected function blockList($Line)

protected function blockListContinue($Line, array $Block)
{
if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches)) {
if ($Block['indent'] === $Line['indent'] && preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches)) {
if (isset($Block['interrupted'])) {
$Block['li']['text'][] = '';

Expand All @@ -539,7 +539,7 @@ protected function blockListContinue($Line, array $Block)
return $Block;
}

if ($Line['text'][0] === '[' and $this->blockReference($Line)) {
if ($Line['text'][0] === '[' && $this->blockReference($Line)) {
return $Block;
}

Expand Down Expand Up @@ -597,7 +597,7 @@ protected function blockQuote($Line)

protected function blockQuoteContinue($Line, array $Block)
{
if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) {
if ($Line['text'][0] === '>' && preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) {
if (isset($Block['interrupted'])) {
$Block['element']['text'][] = '';

Expand Down Expand Up @@ -637,7 +637,7 @@ protected function blockRule($Line)

protected function blockSetextHeader($Line, array $Block = null)
{
if (!isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) {
if (!isset($Block) || isset($Block['type']) || isset($Block['interrupted'])) {
return;
}

Expand All @@ -653,7 +653,7 @@ protected function blockSetextHeader($Line, array $Block = null)

protected function blockMarkup($Line)
{
if ($this->markupEscaped or $this->safeMode) {
if ($this->markupEscaped || $this->safeMode) {
return;
}

Expand All @@ -675,13 +675,13 @@ protected function blockMarkup($Line)
$remainder = substr($Line['text'], $length);

if (trim($remainder) === '') {
if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) {
if (isset($matches[2]) || in_array($matches[1], $this->voidElements)) {
$Block['closed'] = true;

$Block['void'] = true;
}
} else {
if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) {
if (isset($matches[2]) || in_array($matches[1], $this->voidElements)) {
return;
}

Expand Down Expand Up @@ -755,11 +755,11 @@ protected function blockReference($Line)

protected function blockTable($Line, array $Block = null)
{
if (!isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) {
if (!isset($Block) || isset($Block['type']) || isset($Block['interrupted'])) {
return;
}

if (strpos($Block['element']['text'], '|') !== false and rtrim($Line['text'], ' -:|') === '') {
if (strpos($Block['element']['text'], '|') !== false && rtrim($Line['text'], ' -:|') === '') {
$alignments = [];

$divider = $Line['text'];
Expand Down Expand Up @@ -858,7 +858,7 @@ protected function blockTableContinue($Line, array $Block)
return;
}

if ($Line['text'][0] === '|' or strpos($Line['text'], '|')) {
if ($Line['text'][0] === '|' || strpos($Line['text'], '|')) {
$Elements = [];

$row = $Line['text'];
Expand Down Expand Up @@ -958,7 +958,7 @@ public function line($text, $nonNestables = [])
foreach ($this->InlineTypes[$marker] as $inlineType) {
// check to see if the current inline type is nestable in the current context

if (!empty($nonNestables) and in_array($inlineType, $nonNestables)) {
if (!empty($nonNestables) && in_array($inlineType, $nonNestables)) {
continue;
}

Expand All @@ -970,7 +970,7 @@ public function line($text, $nonNestables = [])

// makes sure that the inline belongs to "our" marker

if (isset($Inline['position']) and $Inline['position'] > $markerPosition) {
if (isset($Inline['position']) && $Inline['position'] > $markerPosition) {
continue;
}

Expand Down Expand Up @@ -1039,7 +1039,7 @@ protected function inlineCode($Excerpt)

protected function inlineEmailTag($Excerpt)
{
if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches)) {
if (strpos($Excerpt['text'], '>') !== false && preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches)) {
$url = $matches[1];

if (!isset($matches[2])) {
Expand Down Expand Up @@ -1067,7 +1067,7 @@ protected function inlineEmphasis($Excerpt)

$marker = $Excerpt['text'][0];

if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches)) {
if ($Excerpt['text'][1] === $marker && preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches)) {
$emphasis = 'strong';
} elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches)) {
$emphasis = 'em';
Expand All @@ -1087,7 +1087,7 @@ protected function inlineEmphasis($Excerpt)

protected function inlineEscapeSequence($Excerpt)
{
if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters)) {
if (isset($Excerpt['text'][1]) && in_array($Excerpt['text'][1], $this->specialCharacters)) {
return [
'markup' => $Excerpt['text'][1],
'extent' => 2,
Expand All @@ -1097,7 +1097,7 @@ protected function inlineEscapeSequence($Excerpt)

protected function inlineImage($Excerpt)
{
if (!isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[') {
if (!isset($Excerpt['text'][1]) || $Excerpt['text'][1] !== '[') {
return;
}

Expand Down Expand Up @@ -1190,25 +1190,25 @@ protected function inlineLink($Excerpt)

protected function inlineMarkup($Excerpt)
{
if ($this->markupEscaped or $this->safeMode or strpos($Excerpt['text'], '>') === false) {
if ($this->markupEscaped || $this->safeMode || strpos($Excerpt['text'], '>') === false) {
return;
}

if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w[\w-]*[ ]*>/s', $Excerpt['text'], $matches)) {
if ($Excerpt['text'][1] === '/' && preg_match('/^<\/\w[\w-]*[ ]*>/s', $Excerpt['text'], $matches)) {
return [
'markup' => $matches[0],
'extent' => strlen($matches[0]),
];
}

if ($Excerpt['text'][1] === '!' and preg_match('/^<!---?[^>-](?:-?[^-])*-->/s', $Excerpt['text'], $matches)) {
if ($Excerpt['text'][1] === '!' && preg_match('/^<!---?[^>-](?:-?[^-])*-->/s', $Excerpt['text'], $matches)) {
return [
'markup' => $matches[0],
'extent' => strlen($matches[0]),
];
}

if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w[\w-]*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches)) {
if ($Excerpt['text'][1] !== ' ' && preg_match('/^<\w[\w-]*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches)) {
return [
'markup' => $matches[0],
'extent' => strlen($matches[0]),
Expand All @@ -1218,7 +1218,7 @@ protected function inlineMarkup($Excerpt)

protected function inlineSpecialCharacter($Excerpt)
{
if ($Excerpt['text'][0] === '&' and !preg_match('/^&#?\w+;/', $Excerpt['text'])) {
if ($Excerpt['text'][0] === '&' && !preg_match('/^&#?\w+;/', $Excerpt['text'])) {
return [
'markup' => '&amp;',
'extent' => 1,
Expand All @@ -1241,7 +1241,7 @@ protected function inlineStrikethrough($Excerpt)
return;
}

if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches)) {
if ($Excerpt['text'][1] === '~' && preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches)) {
return [
'extent' => strlen($matches[0]),
'element' => [
Expand All @@ -1255,7 +1255,7 @@ protected function inlineStrikethrough($Excerpt)

protected function inlineUrl($Excerpt)
{
if ($this->urlsLinked !== true or !isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/') {
if ($this->urlsLinked !== true || !isset($Excerpt['text'][2]) || $Excerpt['text'][2] !== '/') {
return;
}

Expand All @@ -1280,7 +1280,7 @@ protected function inlineUrl($Excerpt)

protected function inlineUrlTag($Excerpt)
{
if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches)) {
if (strpos($Excerpt['text'], '>') !== false && preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches)) {
$url = $matches[1];

return [
Expand Down Expand Up @@ -1372,7 +1372,7 @@ protected function li($lines)

$trimmedMarkup = trim($markup);

if (!in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '<p>') {
if (!in_array('', $lines) && substr($trimmedMarkup, 0, 3) === '<p>') {
$markup = $trimmedMarkup;
$markup = substr($markup, 3);

Expand Down

0 comments on commit fffa67c

Please sign in to comment.