Completed
Push — master ( ddcbf1...743278 )
by Thomas
04:16 queued 01:18
created

CommentsFormatter::doVisitToken()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 13.2951

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 17
ccs 4
cts 13
cp 0.3076
rs 8.8571
cc 5
eloc 10
nc 3
nop 1
crap 13.2951
1
<?php
2
namespace gossi\formatter\formatters;
3
4
use phootwork\tokenizer\Token;
5
6
class CommentsFormatter extends SpecializedFormatter {
7
8 2
	protected function doVisitToken(Token $token) {
9
		// multiline
10 2
		if ($token->type == T_DOC_COMMENT
11 2
				|| $token->type == T_INLINE_HTML && strpos($token->contents, '/*') !== 0) {
12
13
			$lines = explode("\n", $token->contents);
14
			$firstLine = array_shift($lines);
15
			$this->writer->writeln();
16
			$this->writer->writeln($firstLine);
17
18
			foreach ($lines as $line) {
19
				$this->writer->writeln(' ' . ltrim($line));
20
			}
21
22
			$this->defaultFormatter->hideToken();
23
		}
24 2
	}
25
26 5
	public static function isComment(Token $token) {
27 5
		return $token->type == T_DOC_COMMENT
28 5
				|| ($token->type == T_INLINE_HTML && strpos($token->contents, '/*') !== 0)
29 5
				|| $token->type == T_COMMENT;
30
	}
31
}
32