### HtmlBlockParser   A last analyzed 2020-07-29 13:18 UTC

#### Complexity

 Total Complexity 12

#### Size/Duplication

 Total Lines 62 Duplicated Lines 0 %

#### Test Coverage

 Coverage 100%

#### Importance

 Changes 0
Metric Value
wmc 12
eloc 19
dl 0
loc 62
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0

#### 5 Methods

Rating   Name   Duplication   Size   Complexity
A closeBlock() 0 4 1
A tryContinue() 0 11 4
A getBlock() 0 3 1
 1  9  * 10  * For the full copyright and license information, please view the LICENSE 11  * file that was distributed with this source code. 12  */ 13 14 namespace League\CommonMark\Extension\CommonMark\Parser\Block; 15 16 use League\CommonMark\Extension\CommonMark\Node\Block\HtmlBlock; 17 use League\CommonMark\Node\Block\AbstractBlock; 18 use League\CommonMark\Parser\Block\AbstractBlockContinueParser; 19 use League\CommonMark\Parser\Block\BlockContinue; 20 use League\CommonMark\Parser\Block\BlockContinueParserInterface; 21 use League\CommonMark\Parser\Cursor; 22 use League\CommonMark\Util\RegexHelper; 23 24 final class HtmlBlockParser extends AbstractBlockContinueParser 25 { 26  /** 27  * @var HtmlBlock 28  * 29  * @psalm-readonly 30  */ 31  private $block; 32 33  /** @var string */ 34  private$content = ''; 35 36  /** @var bool */ 37  private $finished = false; 38 39 168  public function __construct(int$blockType) 40  { 41 168  $this->block = new HtmlBlock($blockType); 42 168  } 43 44  /** 45  * @return HtmlBlock 46  */ 47 168  public function getBlock(): AbstractBlock 48  { 49 168  return $this->block; 50  } 51 52 153  public function tryContinue(Cursor$cursor, BlockContinueParserInterface $activeBlockParser): ?BlockContinue 53  { 54 153  if ($this->finished) { 55 48  return BlockContinue::none(); 0 ignored issues – show Bug introduced 2020-06-27 13:42 UTC by Are you sure the usage of League\CommonMark\Parser...k\BlockContinue::none() targeting League\CommonMark\Parser...k\BlockContinue::none() seems to always return null. This check looks for function or method calls that always return null and whose return value is used. class A { function getObject() { return null; } } $a = new A(); if ($a->getObject()) {  The method getObject() can return nothing but null, so it makes no sense to use the return value. The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history... 56  } 57 58 138  if ($cursor->isBlank() && \in_array($this->block->getType(), [HtmlBlock::TYPE_6_BLOCK_ELEMENT, HtmlBlock::TYPE_7_MISC_ELEMENT], true)) { 59 48  return BlockContinue::none(); 0 ignored issues – show Bug introduced 2020-06-27 13:42 UTC by Are you sure the usage of League\CommonMark\Parser...k\BlockContinue::none() targeting League\CommonMark\Parser...k\BlockContinue::none() seems to always return null. This check looks for function or method calls that always return null and whose return value is used. class A { function getObject() { return null; } } $a = new A(); if ($a->getObject()) {  The method getObject() can return nothing but null, so it makes no sense to use the return value. The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history... 60  } 61 62 117  return BlockContinue::at($cursor); 63  } 64 65 168  public function addLine(string$line): void 66  { 67 168  if ($this->content !== '') { 68 117 $this->content .= "\n"; 69  } 70 71 168  $this->content .=$line; 72 73  // Check for end condition 74  // phpcs:disable SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed 75 168  if ($this->block->getType() >= HtmlBlock::TYPE_1_CODE_CONTAINER &&$this->block->getType() <= HtmlBlock::TYPE_5_CDATA) { 76 57  if (\preg_match(RegexHelper::getHtmlBlockCloseRegex($this->block->getType()),$line) === 1) { 77 54  $this->finished = true; 78  } 79  } 80 168  } 81 82 168  public function closeBlock(): void 83  { 84 168 $this->block->setLiteral($this->content); 85 168 $this->content = ''; 86 168  } 87 } 88