Completed
Push — master ( da17ac...286914 )
by George
03:50
created

ValidateVersion::validateVersionNumber()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 2
eloc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Stats\Decorators;
4
5
/**
6
 * Decorator for objects which validate a version number.
7
 *
8
 * @since  1.0
9
 */
10
trait ValidateVersion
11
{
12
	/**
13
	 * Validates and filters the version number
14
	 *
15
	 * @param   string  $version  The version string to validate.
16
	 *
17
	 * @return  string|boolean  A validated version number on success or boolean false.
18
	 *
19
	 * @since   1.0
20
	 */
21 3
	protected function validateVersionNumber($version)
22
	{
23 3
		return preg_match('/\d+(?:\.\d+)+/', $version, $matches) ? $matches[0] : false;
24
	}
25
}
26