Type::isSame()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace PHPSemVerChecker\Comparator;
4
5
use PhpParser\Node\NullableType;
6
7
class Type
8
{
9
	/**
10
	 * @param \PhpParser\Node\Name|string|null $typeA
11
	 * @param \PhpParser\Node\Name|string|null $typeB
12
	 * @return bool
13
	 */
14 6
	public static function isSame($typeA, $typeB)
15
	{
16 6
		$typeA = self::get($typeA);
17 6
		$typeB = self::get($typeB);
18 6
		return $typeA === $typeB;
19
	}
20
21
	/**
22
	 * @param \PhpParser\Node\Name|\PhpParser\Node\NullableType|string|null $type
23
	 * @return string|null
24
	 */
25 78
	public static function get($type)
26
	{
27 78
		if (! is_object($type)) {
28 32
			return $type;
29
		}
30
31 62
		if ($type instanceof NullableType) {
32 2
			return '?'.static::get($type->type);
33
		}
34
35 62
		return $type->toString();
36
	}
37
}
38