Schema/Library.pm

filter: Statementstmt 78.9% 30 / 38 Branchbran 50.0% 5 / 10 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 4 totaltotal 66.6% 44 / 66 CC 10 SCAR 15.6
CC
10
Cov
71%
find_all
12.0
add
5.5
find
3.1
CRAP 4.7
« Schema/RootNode.pm ↑ Summary Schema.pm »
1 package XML::Validator::Schema::Library;
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 6 ▶use XML::Validator::Schema::Util qw(XSD _err);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 XML::Validator::Schema::TypeLibrary
11  
12 =head1 DESCRIPTION
13  
14 Internal base class used to implement a libraries of named items.
15  
16 =cut
17  
18 154 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
19 154 my $pkg = shift;
20 154 my $self = bless({@_}, $pkg);
21  
22 croak("Missing required 'what' parameter.")
23 154 ▶ unless $self->{what};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"what"} 0 154 154
24
25 # initialize stacks
26 154 $self->{stacks} = {};
27  
28 154 return $self;
29 }
30  
31 0 ▶sub find_all {
Subroutine find_all: not called CC=3 SCAR=24.8
Pod undocumented
32 0 my $self = shift;
33 0 my @ret;
34 0 foreach my $ns (keys %{$self->{stacks}}) {
35 0 foreach my $name (keys %{$self->{$ns}}) {
36 0 push @ret, $self->{stacks}{$ns}{$name};
37 }
38 }
39 0 return @ret;
40 }
41  
42 485 ▶sub find {
Subroutine find: called CC=3 SCAR=11.3
Pod undocumented
43 485 my ($self, %arg) = @_;
44 485 ▶ croak("Missing required name parameter.") unless $arg{name};
Branch: 1 branch
BranchTrueFalseTotal
unless $arg{"name"} 0 485 485
45  
46 # HACK: fix when QName resolution works
47 485 $arg{name} =~ s!^[^:]*:!!;
48 485 ▶ $arg{ns} ||= XSD;
Condition50%1/2
$arg{"ns"} ||= "http://www.w3.org/2001/XMLSchema"
l!l
0485
MC/DC0%0/1
$arg{"ns"} ||= "http://www.w3.org/2001/XMLSchema"
$arg{"ns"}
Truth table50%1/2
A
A= $arg{"ns"}
Aresult
11
00
49  
50 485 return $self->{stacks}{$arg{ns}}{$arg{name}};
51 }
52  
53 107 ▶sub add {
Subroutine add: called CC=5 SCAR=17.0
Pod undocumented
54 107 my ($self, %arg) = @_;
55 107 ▶ croak("Missing required name parameter.") unless $arg{name};
Branch: 1 branch
BranchTrueFalseTotal
unless $arg{"name"} 0 107 107
56 107 ▶ croak("Missing required obj parameter.") unless $arg{obj};
Branch: 1 branch
BranchTrueFalseTotal
unless $arg{"obj"} 0 107 107
57
58 # HACK: fix when QName resolution works
59 107 $arg{name} =~ s!^\w+:!!;
60 107 ▶ $arg{ns} ||= XSD;
Condition50%1/2
$arg{"ns"} ||= "http://www.w3.org/2001/XMLSchema"
l!l
0107
MC/DC0%0/1
$arg{"ns"} ||= "http://www.w3.org/2001/XMLSchema"
$arg{"ns"}
Truth table50%1/2
A
A= $arg{"ns"}
Aresult
11
00
61  
62 _err("Illegal attempt to redefine $self->{what} '$arg{name}' ".
63 "in namespace '$arg{ns}'")
64 107 ▶ if exists $self->{stacks}{$arg{ns}}{$arg{name}};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"stacks"}{$arg{"ns"}}{$arg{"name"}} 0 107 107
65 107 $self->{stacks}{$arg{ns}}{$arg{name}} = $arg{obj};
66 }
67  
68 6 1;
« Schema/RootNode.pm ↑ Summary Schema.pm »