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

Comments   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 20
Duplicated Lines 40 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 9
lcom 0
cbo 0
dl 8
loc 20
rs 10
c 1
b 1
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tokenize() 0 4 1
A singleLineComments() 4 6 4
A multiLinecomments() 4 6 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}