Skip to content

Commit 403af24

Browse files
committed
Removed unnecessary else by returning early
1 parent 6959035 commit 403af24

File tree

5 files changed

+22
-30
lines changed

5 files changed

+22
-30
lines changed

src/CommonMark/IndentedCodeBlockRenderer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function render(Node $node, ChildNodeRendererInterface $childRenderer)
3535

3636
if ($theme instanceof WebTheme) {
3737
return $theme->preBefore($highlighter) . $parsed . $theme->preAfter($highlighter);
38-
} else {
39-
return '<pre data-lang="' . $language . '" class="notranslate">' . $parsed . '</pre>';
4038
}
39+
40+
return sprintf('<pre data-lang="%s" class="notranslate">%s</pre>', $language, $parsed);
4141
}
4242
}

src/Languages/CommonPatterns/DoubleQuoteValuePattern.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ final class DoubleQuoteValuePattern implements Pattern
1818

1919
public function __construct(
2020
private string $tokenType = 'hl-value',
21-
) {
21+
)
22+
{
2223
}
2324

2425
public function canNotContain(): self
@@ -35,13 +36,10 @@ public function getPattern(): string
3536

3637
public function getTokenType(): TokenType
3738
{
38-
if ($this->canNotContain)
39-
{
39+
if ($this->canNotContain) {
4040
return new CanNotContainTokenType($this->tokenType);
4141
}
42-
else
43-
{
44-
return new DynamicTokenType($this->tokenType);
45-
}
42+
43+
return new DynamicTokenType($this->tokenType);
4644
}
4745
}

src/Languages/CommonPatterns/GenericPattern.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ final class GenericPattern implements Pattern
1919
public function __construct(
2020
private string $pattern,
2121
private string $tokenType,
22-
) {
22+
)
23+
{
2324
}
2425

2526
public function canNotContain(): self
@@ -36,13 +37,10 @@ public function getPattern(): string
3637

3738
public function getTokenType(): TokenType
3839
{
39-
if ($this->canNotContain)
40-
{
40+
if ($this->canNotContain) {
4141
return new CanNotContainTokenType($this->tokenType);
4242
}
43-
else
44-
{
45-
return new DynamicTokenType($this->tokenType);
46-
}
43+
44+
return new DynamicTokenType($this->tokenType);
4745
}
4846
}

src/Languages/CommonPatterns/KeywordPattern.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ final class KeywordPattern implements Pattern
2121
public function __construct(
2222
private string $keyword,
2323
private string $tokenType = 'hl-keyword',
24-
) {
24+
)
25+
{
2526
}
2627

2728
public function caseInsensitive(): self
@@ -51,13 +52,10 @@ public function getPattern(): string
5152

5253
public function getTokenType(): TokenType
5354
{
54-
if ($this->canNotContain)
55-
{
55+
if ($this->canNotContain) {
5656
return new CanNotContainTokenType($this->tokenType);
5757
}
58-
else
59-
{
60-
return new DynamicTokenType($this->tokenType);
61-
}
58+
59+
return new DynamicTokenType($this->tokenType);
6260
}
6361
}

src/Languages/CommonPatterns/SingleQuoteValuePattern.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ final class SingleQuoteValuePattern implements Pattern
1818

1919
public function __construct(
2020
private string $tokenType = 'hl-value',
21-
) {
21+
)
22+
{
2223
}
2324

2425
public function canNotContain(): self
@@ -35,13 +36,10 @@ public function getPattern(): string
3536

3637
public function getTokenType(): TokenType
3738
{
38-
if ($this->canNotContain)
39-
{
39+
if ($this->canNotContain) {
4040
return new CanNotContainTokenType($this->tokenType);
4141
}
42-
else
43-
{
44-
return new DynamicTokenType($this->tokenType);
45-
}
42+
43+
return new DynamicTokenType($this->tokenType);
4644
}
4745
}

0 commit comments

Comments
 (0)