Filter/EntityReference.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 29 CC 3 SCAR 19.5
CC
3
Cov
0%
filter
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 7.0
1 package HTML::MobileJp::Filter::EntityReference;
2 use Any::Moose;
3  
4 with 'HTML::MobileJp::Filter::Role';
5  
6 has '+config' => (
7 default => sub {{
8 force => 0,
9 }},
10 );
11  
12 use Encode::JP::Mobile ':props';
13 use HTML::Entities::ConvertPictogramMobileJp;
14  
15 sub filter {
16 my ($self, $content) = @_;
17
18 if ($self->mobile_agent->is_non_mobile) {
19 if ($self->config->{force}) {
20 $content =~ s{(&\#x([A-Z0-9]+);)}{
21 my $code = $1;
22 my $char = chr hex $2;
23 $char =~ /\p{InMobileJPPictograms}/ ? $char : $code;
24 }ge;
25 }
26 } else {
27 $content = convert_pictogram_entities(
28 mobile_agent => $self->mobile_agent,
29 html => $content->stringfy,
30 );
31 }
32
33 $content;
34 }
35  
36 __PACKAGE__->meta->make_immutable;
37  
38 1;
39 __END__