Completed
Push — mysql_improvements ( 2e95ce...dedbef )
by Michael
03:52
created

ValidateVersion   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 14
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateVersionNumber() 0 4 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