lib/MKDoc/XML/Encode.pm

filter: Statementstmt 100% 15 / 15 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 91.3% 21 / 23 CC 3 SCAR 8.1
CC
3
Cov
89%
process
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« lib/MKDoc/XML/Tokenizer.pm ↑ Summary lib/MKDoc/XML/Decode.pm »
1 # -------------------------------------------------------------------------------------
2 # MKDoc::XML::Encode
3 # -------------------------------------------------------------------------------------
4 # Author : Jean-Michel Hiver.
5 # Copyright : (c) MKDoc Holdings Ltd, 2003
6 #
7 # This modules encodes XML entities & > < " and '.
8 #
9 # This module is distributed under the same license as Perl itself.
10 # -------------------------------------------------------------------------------------
11 package MKDoc::XML::Encode;
12 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 6 our %XML_Encode = (
16 '&' => 'amp',
17 '<' => 'lt',
18 '>' => 'gt',
19 '"' => 'quot',
20 "'" => 'apos',
21 );
22  
23 6 our $XML_Encode_Pattern = join ("|", keys %XML_Encode);
24  
25  
26 sub process
27 48 ▶{
Subroutine process: called CC=3 SCAR=11.2
Pod documented
28 48 ▶ (@_ == 2) or warn "MKDoc::XML::Encode::process() should be called with two arguments";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or warn "MKDoc::XML::Encode::process() should be called with two arguments" 48 0 48
29
30 48 my $class = shift;
31 48 ▶ my $data = join '', map { (defined $_) ? $_ : '' } @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 48 0 48
32 48 $data =~ s/($XML_Encode_Pattern)/&$XML_Encode{$1};/go;
33 48 return $data;
34 }
35  
36  
37 6 1;
38  
39  
40 __END__
« lib/MKDoc/XML/Tokenizer.pm ↑ Summary lib/MKDoc/XML/Decode.pm »