Completed
Push — master ( f4bdff...fef961 )
by Thomas
01:46
created

IndentationFormatter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 20
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A doVisitToken() 0 4 1
A indentOpenCurlyBrace() 0 5 2
A indentCloseCurlyBrace() 0 5 2
1
<?php
2
namespace gossi\formatter\formatters;
3
4
use phootwork\tokenizer\Token;
5
6
class IndentationFormatter extends SpecializedFormatter {
7
8
	protected function doVisitToken(Token $token) {
9
		$this->indentOpenCurlyBrace($token);
10
		$this->indentCloseCurlyBrace($token);
11
	}
12
13
	private function indentOpenCurlyBrace(Token $token) {
14
		if ($token->contents == '{') {
15
			$this->defaultFormatter->addPostIndent();
16
		}
17
	}
18
19
	private function indentCloseCurlyBrace(Token $token) {
20
		if ($token->contents == '}') {
21
			$this->defaultFormatter->addPreOutdent();
22
		}
23
	}
24
25
}
26