IdHelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 22
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A isId() 0 12 3
1
<?php
2
3
/**
4
 * This software package is licensed under AGPL or Commercial license.
5
 *
6
 * @package maslosoft/mangan
7
 * @licence AGPL or Commercial
8
 * @copyright Copyright (c) Piotr Masełkowski <[email protected]>
9
 * @copyright Copyright (c) Maslosoft
10
 * @copyright Copyright (c) Others as mentioned in code
11
 * @link https://maslosoft.com/mangan/
12
 */
13
14
namespace Maslosoft\Mangan\Helpers;
15
16
use MongoId;
17
18
/**
19
 * IdHelper
20
 *
21
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
22
 */
23
class IdHelper
24
{
25
26
	/**
27
	 * Check if provided value id mongo id compatible
28
	 * @param MongoId $mongoId
29
	 * @return boolean true if it's MongoId compatible string or MongoId instance
30
	 */
31
	public static function isId($mongoId)
32
	{
33
		if ($mongoId instanceof MongoId)
34
		{
35
			return true;
36
		}
37
		if (preg_match('^[a-f0-9]{24}$', $mongoId))
38
		{
39
			return true;
40
		}
41
		return false;
42
	}
43
44
}
45