@@ 54-65 (lines=12) @@ | ||
51 | * @throws InvalidArgumentException If the version number is not in a recognized format. |
|
52 | */ |
|
53 | public function normalizeVersion( $version ) { |
|
54 | if ( is_array( $version ) ) { |
|
55 | $info = $version + array( |
|
56 | 'prerelease' => null, |
|
57 | 'buildinfo' => null, |
|
58 | ); |
|
59 | $test = $this->parseVersion( '0.0.0' ); |
|
60 | if ( array_intersect_key( $test, $info ) !== $test ) { |
|
61 | throw new InvalidArgumentException( 'Version array is not in a recognized format.' ); |
|
62 | } |
|
63 | } else { |
|
64 | $info = $this->parseVersion( $version ); |
|
65 | } |
|
66 | ||
67 | $ret = sprintf( '%d.%d.%d', $info['major'], $info['minor'], $info['patch'] ); |
|
68 | if ( null !== $info['prerelease'] ) { |
@@ 70-81 (lines=12) @@ | ||
67 | */ |
|
68 | public function normalizeVersion( $version ) { |
|
69 | // The ability to pass an array is an internal-only feature. |
|
70 | if ( is_array( $version ) ) { |
|
71 | $info = $version + array( |
|
72 | 'prerelease' => null, |
|
73 | 'buildinfo' => null, |
|
74 | ); |
|
75 | $test = $this->parseVersion( '0.0' ); |
|
76 | if ( array_intersect_key( $test, $info ) !== $test ) { |
|
77 | throw new InvalidArgumentException( 'Version array is not in a recognized format.' ); |
|
78 | } |
|
79 | } else { |
|
80 | $info = $this->parseVersion( $version ); |
|
81 | } |
|
82 | ||
83 | $ret = sprintf( '%.1f', $info['major'] ); |
|
84 | if ( 0 !== $info['point'] ) { |