Schema/Attribute.pm

filter: Statementstmt 100% 30 / 30 Branchbran 78.5% 11 / 14 Conditioncond 75.0% 6 / 8 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 82.8% 53 / 64 CC 11 SCAR 21.4
CC
11
Cov
90%
parse
11.2
BEGIN
1.0
BEGIN
1.0
CRAP 8.5
« Schema/ElementNode.pm ↑ Summary Schema/ModelNode.pm »
1 package XML::Validator::Schema::Attribute;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 =head1 NAME
6  
7 XML::Validator::Schema::Attribute - an attribute node in a schema object
8  
9 =head1 DESCRIPTION
10  
11 This is an internal module used by XML::Validator::Schema to represent
12 attributes derived from XML Schema documents.
13  
14 =cut
15  
16 5 ▶use XML::Validator::Schema::Util qw(_attr _err);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 27 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
19 27 my ($pkg, %arg) = @_;
20 27 my $self = bless \%arg, $pkg;
21 }
22  
23 # create an attribute based on the contents of an element hash
24 27 ▶sub parse {
Subroutine parse: called CC=11 SCAR=24.2
Pod undocumented
25 27 my ($pkg, $data) = @_;
26 27 my $self = $pkg->new();
27  
28 27 my $name = _attr($data, 'name');
29 27 ▶ $self->{name} = $name if $name;
Branch: 1 branch
BranchTrueFalseTotal
if $name 26 1 27
30  
31 27 my $ref = _attr($data, 'ref');
32 27 ▶ if ($ref) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref) 1 26 27
33 1 ▶ _err("Illegal combination of 'ref' and 'name' in <attribute>.")
Branch: 1 branch
BranchTrueFalseTotal
if $name 0 1 1
34 if $name;
35 1 $self->{unresolved_ref} = 1;
36 1 $self->{name} = $ref;
37 }
38  
39 27 ▶ _err("Found <attribute> with neither 'name' nor 'ref'.")
Branch: 1 branch
BranchTrueFalseTotal
unless $name or $ref 0 27 27
Condition66%2/3
$name or $ref
l!l&&r!l&&!r
2610
MC/DC0%0/2
$name or $ref
$name $ref
Truth table66%2/3
A or B
A= $nameB= $ref
ABresult
1X1
011
000
40 unless $name or $ref;
41  
42 27 my $type_name = _attr($data, 'type');
43 27 ▶ if ($type_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type_name) 21 6 27
44 21 $self->{unresolved_type} = 1;
45 21 $self->{type_name} = $type_name;
46 }
47
48 # load use, defaults to optional
49 27 ▶ my $use = _attr($data, 'use') || 'optional';
Condition100%2/2
_attr($data, 'use') || 'optional'
l!l
225
MC/DC100%1/1
_attr($data, 'use') || 'optional'
_attr($data, 'use')
Truth table100%2/2
A
A= _attr($data, 'use')
Aresult
11
00
50 27 ▶ _err("Invalid 'use' value in <attribute name='$name'>: '$use'.")
Branch: 1 branch
BranchTrueFalseTotal
unless $use eq "optional" or $use eq "required" 0 27 27
Condition66%2/3
$use eq "optional" or $use eq "required"
l!l&&r!l&&!r
1890
MC/DC0%0/2
$use eq "optional" or $use eq "required"
$use eq "optional" $use eq "required"
Truth table66%2/3
A or B
A= $use eq "optional"B= $use eq "required"
ABresult
1X1
011
000
51 unless $use eq 'optional' or $use eq 'required';
52 27 ▶ $self->{required} = $use eq 'required' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$use eq 'required' ? : 9 18 27
53  
54 27 return $self;
55 }
56  
57 5 1;
58  
« Schema/ElementNode.pm ↑ Summary Schema/ModelNode.pm »