Completed
Push — master ( 1a6e67...071a29 )
by Tomáš
02:38
created

PositionFinder::findLastPositionInCurrentLine()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 11
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 2
crap 2
1
<?php
2
3
declare(strict_types = 1);
4
5
/*
6
 * This file is part of Zenify
7
 * Copyright (c) 2012 Tomas Votruba (http://tomasvotruba.cz)
8
 */
9
10
namespace ZenifyCodingStandard\Helper;
11
12
use PHP_CodeSniffer_File;
13
14
15
final class PositionFinder
16
{
17
18 1 View Code Duplication
	public static function findFirstPositionInCurrentLine(PHP_CodeSniffer_File $file, int $position) : int
19
	{
20 1
		$currentPosition = $position;
21
22 1
		$line = $file->getTokens()[$position]['line'];
23 1
		while ($file->getTokens()[$currentPosition]['line'] === $line) {
24 1
			$currentPosition--;
25
		}
26
27 1
		return $currentPosition;
28
	}
29
30
31 1 View Code Duplication
	public static function findLastPositionInCurrentLine(PHP_CodeSniffer_File $file, int $position) : int
32
	{
33 1
		$currentPosition = $position;
34
35 1
		$line = $file->getTokens()[$position]['line'];
36 1
		while ($file->getTokens()[$currentPosition]['line'] === $line) {
37 1
			$currentPosition++;
38
		}
39
40 1
		return $currentPosition;
41
	}
42
43
}
44