From 665bfa90e35c1d0d13904dcd0be206f80845a250 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse <guillaume.rousse@renater.fr> Date: Fri, 3 Nov 2017 14:36:20 +0100 Subject: [PATCH] use a local private function --- lib/IdPAccountManager/SAMLMetadata.pm | 22 ++++++++++++++-------- lib/IdPAccountManager/Tools.pm | 13 ------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/lib/IdPAccountManager/SAMLMetadata.pm b/lib/IdPAccountManager/SAMLMetadata.pm index 1025ba1..6426bc0 100644 --- a/lib/IdPAccountManager/SAMLMetadata.pm +++ b/lib/IdPAccountManager/SAMLMetadata.pm @@ -98,14 +98,14 @@ sub parse { binding => $sso->getAttribute('Binding'), location => $sso->getAttribute('Location'), index => $sso->getAttribute('index'), - isdefault => IdPAccountManager::Tools::boolean2integer( + isdefault => _boolean2integer( $sso->getAttribute('isDefault') ) }; } - foreach my $requestedattribute ( + foreach my $attribute ( $child->getElementsByLocalName('RequestedAttribute')) { @@ -114,15 +114,14 @@ sub parse { { 'friendly_name' => IdPAccountManager::Tools::encode_utf8( - $requestedattribute->getAttribute('FriendlyName') + $attribute->getAttribute('FriendlyName') ), 'name' => IdPAccountManager::Tools::encode_utf8( - $requestedattribute->getAttribute('Name') + $attribute->getAttribute('Name') ), - 'is_required' => - IdPAccountManager::Tools::boolean2integer( - $requestedattribute->getAttribute('isRequired') - ) + 'is_required' => _boolean2integer( + $attribute->getAttribute('isRequired') + ) }; } @@ -251,6 +250,13 @@ sub print { print $fd $root->toString(); } +sub _boolean2integer { + return + $_[0] eq 'true' ? 1 : + $_[0] eq 'false' ? 0 : + undef; +} + 1; __END__ diff --git a/lib/IdPAccountManager/Tools.pm b/lib/IdPAccountManager/Tools.pm index 7d1dcf6..4af9e28 100644 --- a/lib/IdPAccountManager/Tools.pm +++ b/lib/IdPAccountManager/Tools.pm @@ -211,19 +211,6 @@ sub escape_quotes { return $string; } -## returns an integer (0 or 1), given an input string ('true' or 'false') -sub boolean2integer { - my ($boolean) = @_; - - if ($boolean eq 'true') { - return 1; - } elsif ($boolean eq 'false') { - return 0; - } - - return undef; -} - 1; __END__ -- GitLab