Bug 9239: Introduce QueryParser driver for PQF
[koha.git] / Koha / QueryParser / Driver / PQF / Util.pm
1 package Koha::QueryParser::Driver::PQF::Util;
2 use Scalar::Util qw(looks_like_number);
3
4 use strict;
5 use warnings;
6
7 sub attributes_to_attr_string {
8     my ($attributes) = @_;
9     my $attr_string = '';
10     my $key;
11     my $value;
12     while (($key, $value) = each(%$attributes)) {
13         next unless looks_like_number($key);
14         $attr_string .= ' @attr ' . $key . '=' . $value . ' ';
15     }
16     $attr_string =~ s/^\s*//;
17     $attr_string =~ s/\s*$//;
18     $attr_string .= ' ' . $attributes->{''} if defined $attributes->{''};
19     return $attr_string;
20 }
21
22 1;