SectionNode::close()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
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
use Htsl\Parser\Section;
9
10
////////////////////////////////////////////////////////////////
11
12
class SectionNode extends ANode
13
{
14
	/**
15
	 * The name of the section.
16
	 *
17
	 * @access protected
18
	 *
19
	 * @var string
20
	 */
21
	protected $name;
22
23
	/**
24
	 * Real constructor.
25
	 *
26
	 * @access protected
27
	 *
28
	 * @return \Htsl\Parser\Node\Contracts\ANode
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use SectionNode.

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...
29
	 */
30
	protected function construct():parent
31
	{
32
		$this->name= $this->line->pregGet('/(?<=\( ).*(?= \))/');
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...
33
34
		return $this;
35
	}
36
37
	/**
38
	 * Opening this node, and returning node opener.
39
	 *
40
	 * @access public
41
	 *
42
	 * @return string
43
	 */
44
	public function open():string
45
	{
46
		$this->document->setSection(new Section($this->name));
47
48
		return '';
49
	}
50
51
	/**
52
	 * Close this node, and returning node closer.
53
	 *
54
	 * @access public
55
	 *
56
	 * @param  \Htsl\ReadingBuffer\Line   $closerLine  The line when node closed.
57
	 *
58
	 * @return string
59
	 */
60
	public function close( Line$closerLine ):string
61
	{
62
		$this->document->setSection(null);
63
64
		return '';
65
	}
66
}
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...
67