TagNameComparator   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 13
dl 0
loc 22
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A compare() 0 21 5
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of the Docblock package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @license MIT License
8
 */
9
10
namespace phpowermove\docblock;
11
12
use phootwork\lang\Comparator;
13
14
class TagNameComparator implements Comparator {
15 4
	public function compare($a, $b): int {
16 4
		$order = ['see', 'author', 'property-read', 'property-write', 'property',
17
				'method', 'deprecated', 'since', 'version', 'var', 'type', 'param',
18
				'throws', 'return'];
19
20 4
		if ($a == $b) {
21 2
			return 0;
22
		}
23
24 4
		if (!in_array($a, $order)) {
25 1
			return -1;
26
		}
27
28 4
		if (!in_array($b, $order)) {
29 1
			return 1;
30
		}
31
32 4
		$pos1 = array_search($a, $order);
33 4
		$pos2 = array_search($b, $order);
34
35 4
		return $pos1 < $pos2 ? -1 : 1;
36
	}
37
}
38