Completed
Push — master ( 10f95b...bf15d4 )
by Michael
09:02
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
 * @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