Completed
Push — master ( 10f95b...bf15d4 )
by Michael
09:02
created

ValidateVersion   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
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 16
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
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
 * @since  1.0
15
 */
16
trait ValidateVersion
17
{
18
	/**
19
	 * Validates and filters the version number
20
	 *
21
	 * @param   string  $version  The version string to validate.
22
	 *
23
	 * @return  string|boolean  A validated version number on success or boolean false.
24
	 *
25
	 * @since   1.0
26
	 */
27 3
	protected function validateVersionNumber(string $version)
28
	{
29 3
		return preg_match('/\d+(?:\.\d+)+/', $version, $matches) ? $matches[0] : false;
30
	}
31
}
32