Completed
Pull Request — master (#175)
by Tom
05:04 queued 04:06
created

Comments::tokenize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
namespace Transphporm\Parser\Tokenizer;
3
use \Transphporm\Parser\Tokenizer;
4
use \Transphporm\Parser\Tokens;
5
6
class Comments implements \Transphporm\Parser\Tokenize {
7
	public function tokenize(TokenizedString $str, Tokens $tokens) {
8
		$this->singleLineComments($str);
9
		$this->multiLinecomments($str);
10
	}
11
12
	private function singleLineComments($str) {
13 View Code Duplication
		if ($str->identifyChar() == Tokenizer::DIVIDE && $str->identifyChar(1) == Tokenizer::DIVIDE) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
			$pos = $str->pos("\n");
15
			$str->move($pos !== false ? $pos : false);
16
		}
17
	}
18
19
	public function multiLinecomments($str) {
20 View Code Duplication
		if ($str->identifyChar() == Tokenizer::DIVIDE && $str->identifyChar(1) == Tokenizer::MULTIPLY) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
			$pos = $str->pos('*/');
22
			$str->move($pos !== false ? $pos+2 : false);
23
		}
24
	}
25
}