Skip to content

Commit 6697208

Browse files
committed
Improve data type to simplify the code
We can make the code more expressive and shorted by using a proper data type.
1 parent 20bf38a commit 6697208

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

manifests/repo/ubuntu.pp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,18 @@
66
# PHP version to manage (e.g. 5.6)
77
#
88
class php::repo::ubuntu (
9-
Optional[String[1]] $version = undef,
9+
Pattern[/^\d\.\d/] $version = '5.6',
1010
) {
1111
if $facts['os']['name'] != 'Ubuntu' {
1212
fail("class php::repo::ubuntu does not work on OS ${facts['os']['name']}")
1313
}
1414
include 'apt'
1515

16-
if($version == undef) {
17-
$version_real = '5.6'
18-
} else {
19-
$version_real = $version
20-
}
21-
22-
if ($version_real == '5.5') {
16+
if ($version == '5.5') {
2317
fail('PHP 5.5 is no longer available for download')
2418
}
25-
assert_type(Pattern[/^\d\.\d/], $version_real)
2619

27-
$version_repo = $version_real ? {
20+
$version_repo = $version ? {
2821
'5.4' => 'ondrej/php5-oldstable',
2922
default => 'ondrej/php'
3023
}

0 commit comments

Comments
 (0)