CommentNode   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 52
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A construct() 0 5 1
A open() 0 6 2
A close() 0 4 2
1
<?php
2
3
namespace Htsl\Parser\Node;
4
5
use Htsl\Htsl;
6
use Htsl\ReadingBuffer\Line;
7
use Htsl\Parser\Node\Contracts\ANode;
8
9
////////////////////////////////////////////////////////////////
10
11
class CommentNode extends ANode
12
{
13
	/**
14
	 * Whether the comment is html comment.
15
	 *
16
	 * @access private
17
	 *
18
	 * @var bool
19
	 */
20
	private $htmlComment;
21
22
	/**
23
	 * Real contructor.
24
	 *
25
	 * @access protected
26
	 *
27
	 * @return \Htsl\Parser\Node\Contracts\ANode
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use CommentNode.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
28
	 */
29
	protected function construct():parent
30
	{
31
		$this->htmlComment= '!'!==$this->line->getChar(1);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned correctly; expected 1 space but found 0 spaces

This check looks for improperly formatted assignments.

Every assignment must have exactly one space before and one space after the equals operator.

To illustrate:

$a = "a";
$ab = "ab";
$abc = "abc";

will have no issues, while

$a   = "a";
$ab  = "ab";
$abc = "abc";

will report issues in lines 1 and 2.

Loading history...
32
		return $this;
33
	}
34
35
	/**
36
	 * Opening this node, and returning node opener.
37
	 *
38
	 * @access public
39
	 *
40
	 * @return string
41
	 */
42
	public function open():string
43
	{
44
		return $this->htmlComment ?
45
		                         '<!--'.str_replace('-->','--'.chr(0xC).'>',substr($this->line->getContent(),1)):
46
		                         '<?php /* '.substr($this->line->getContent(),2);
47
	}
48
49
	/**
50
	 * Close this node, and returning node closer.
51
	 *
52
	 * @access public
53
	 *
54
	 * @param  \Htsl\ReadingBuffer\Line   $closerLine  The line when node closed.
55
	 *
56
	 * @return string
57
	 */
58
	public function close( Line$closerLine ):string
59
	{
60
		return $this->htmlComment ? '-->' : ' */ ?>';
61
	}
62
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
63