Malware.pm

filter: Statementstmt 50.9% 27 / 53 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 63.6% 7 / 11 Podpod 0.0% 0 / 3 totaltotal 43.5% 34 / 78 CC 5 SCAR 19.3
CC
5
Cov
44%
in
20.0
_hash
6.0
new
2.0
CRAP 6.9
↑ Summary example.pl »
1 package XML::Malware;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '0.01';
7 1 $VERSION = eval $VERSION; # see L<perlmodstyle>
8  
9 1 ▶use XML::Compile;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use XML::Compile::Schema;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use XML::Compile::Util qw/pack_type/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 my $type = pack_type 'http://xml/metadataSharing.xsd', 'malwareMetaData';
15 1 XML::Compile->addSchemaDirs(__FILE__);
16 1 ▶use constant MYNS => 'http://xml/metadataSharing.xsd';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 XML::Compile->knownNamespace(&MYNS => 'metadataSharing.xsd');
18  
19 # Preloaded methods go here.
20  
21 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
22 0 my $class = shift;
23 0 my $args = shift;
24 0 my $self = {};
25 0 bless($self,$class);
26 0 $self->_hash($args);
27 0 return($self);
28 }
29  
30 0 ▶sub in {
Subroutine in: not called CC=4 SCAR=30.0
Pod undocumented
31 0 my $self = shift;
32 0 my $xml = shift;
33 0 ▶ return(undef) unless($xml);
Branch: 1 branch
BranchTrueFalseTotal
unless $xml 0 0 0
34  
35 0 my $s = XML::Compile::Schema->new();
36 0 $s->importDefinitions(MYNS);
37  
38 0 my $read = $s->compile(READER => $type);
39 0 my $h = $read->($xml);
40 0 ▶ return(undef) unless($h && ref($h) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
unless $h and ref $h eq "HASH" 0 0 0
Condition0%0/3
$h and ref $h eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
$h and ref $h eq "HASH"
$h ref $h eq "HASH"
Truth table0%0/3
A and B
A= $hB= ref $h eq "HASH"
ABresult
0X0
100
111
41 0 $self->_hash($h);
42 0 return($self->_hash());
43 }
44  
45 0 ▶sub out {
Subroutine out: not called CC=1 SCAR=6.9
Pod undocumented
46 0 my $self = shift;
47 0 my $s = XML::Compile::Schema->new();
48 0 $s->importDefinitions(MYNS);
49 0 my $doc = XML::LibXML::Document->new('1.0', 'UTF-8');
50 0 my $write = $s->compile(WRITER => $type);
51 0 my $xml = $write->($doc, $self->_hash());
52 0 return $xml->toString();
53 }
54  
55 # accessors
56  
57 0 ▶sub _hash {
Subroutine _hash: not called CC=2 SCAR=17.9
58 0 my ($self,$v) = @_;
59 0 ▶ $self->{'_hash'} = $v if(defined($v));
Branch: 1 branch
BranchTrueFalseTotal
if defined $v 0 0 0
60 0 return($self->{'_hash'});
61 }
62  
63 1 1;
64 __END__
↑ Summary example.pl »