Completed
Push — mysql_improvements ( 2e95ce...dedbef )
by Michael
03:52
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 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * Joomla! Statistics Server
4
 *
5
 * @copyright  Copyright (C) 2013 - 2017 Open Source Matters, Inc. All rights reserved.
6
 * @license    http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
7
 */
8
9
namespace Joomla\StatsServer\Decorators;
10
11
/**
12
 * Decorator for objects which validate a version number.
13
 */
14
trait ValidateVersion
15
{
16
	/**
17
	 * Validates and filters the version number
18
	 *
19
	 * @param   string  $version  The version string to validate.
20
	 *
21
	 * @return  string|boolean  A validated version number on success or boolean false.
22
	 */
23 4
	protected function validateVersionNumber(string $version)
24
	{
25 4
		return preg_match('/\d+(?:\.\d+)+/', $version, $matches) ? $matches[0] : false;
26
	}
27
}
28