PML/Schema/Alt.pm

filter: Statementstmt 50.9% 26 / 51 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 71.4% 10 / 14 Podpod 83.3% 5 / 6 totaltotal 42.2% 41 / 97 CC 12 SCAR 43.2
CC
12
Cov
36%
validate_object
156.0
is_atomic
2.0
get_decl_type_str
2.0
CRAP 75.5
« PML/Backend/TrXML.pm ↑ Summary PML/Schema/Import.pm »
1 package Treex::PML::Schema::Alt;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 $VERSION='2.29'; # version template
9 }
10 9 ▶no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 9 ▶use Treex::PML::Schema::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 9 ▶use base qw( Treex::PML::Schema::Decl );
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 =head1 NAME
17  
18 Treex::PML::Schema::Alt - implements declaration of an alternative (alt).
19  
20 =head1 INHERITANCE
21  
22 This class inherits from L<Treex::PML::Schema::Decl>.
23  
24 =head1 METHODS
25  
26 See the super-class for the complete list.
27  
28 =over 3
29  
30 =item $decl->get_decl_type ()
31  
32 Returns the constant PML_ALT_DECL.
33  
34 =item $decl->get_decl_type_str ()
35  
36 Returns the string 'alt'.
37  
38 =item $decl->get_content_decl ()
39  
40 Return type declaration of the list members.
41  
42 =item $decl->is_flat ()
43  
44 Return 1 for ``flat'' alternatives, otherwise return 0. (Flat
45 alternatives are not part of PML specification, but are used for
46 translating attribute values from C<Treex::PML::FSFormat>.)
47  
48 =item $decl->is_atomic ()
49  
50 Returns 0.
51  
52 =back
53  
54 =cut
55  
56 0 ▶sub is_atomic { 0 }
Subroutine is_atomic: not called CC=1 SCAR=6.9
Pod documented
57 73 ▶sub get_decl_type { return PML_ALT_DECL; }
Subroutine get_decl_type: called CC=1 SCAR=0.0
Pod documented
58 0 ▶sub get_decl_type_str { return 'alt'; }
Subroutine get_decl_type_str: not called CC=1 SCAR=6.9
Pod documented
59 0 ▶sub is_flat { return $_[0]->{-flat} }
Subroutine is_flat: not called CC=1 SCAR=6.9
Pod documented
60 10 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
61 10 my ($self,$opts)=@_;
62 10 $self->{-parent}{-decl} = 'alt';
63 }
64  
65 0 ▶sub validate_object {
Subroutine validate_object: not called CC=12 SCAR=50.5
Pod documented
66 0 my ($self, $object, $opts) = @_;
67  
68 0 my ($path,$tag,$flags);
69 0 my $log = [];
70 0 ▶ if (ref($opts)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opts) 0 0 0
71 0 $flags = $opts->{flags};
72 0 $path = $opts->{path};
73 0 $tag = $opts->{tag};
74 0 ▶ $path.="/".$tag if $tag ne q{};
Branch: 1 branch
BranchTrueFalseTotal
if $tag ne "" 0 0 0
75 }
76 0 my $am_decl = $self->get_content_decl;
77 0 ▶ if ($self->is_flat) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->is_flat) { } 0 0 0
elsif (ref $object and UNIVERSAL::DOES::does($object, 'Treex::PML::Alt')) { } 0 0 0
78 # flat alternative:
79 0 ▶ if (ref($object)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $object) { } 0 0 0
80 0 push @$log, "$path: flat alternative is supposed to be a string: $object";
81 } else {
82 0 my $i = 1;
83 0 foreach my $val (split /\|/,$object) {
84 0 $am_decl->validate_object($val, {
85 flags => $flags,
86 path=> $path,
87 tag => "[".($i++)."]",
88 log => $log,
89 });
90 }
91 }
92 ▶ } elsif (ref($object) and UNIVERSAL::DOES::does($object,'Treex::PML::Alt')) {
Condition0%0/3
ref $object and UNIVERSAL::DOES::does($object, "Treex::PML::Alt")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $object and UNIVERSAL::DOES::does($object, "Treex::PML::Alt")
ref $object UNIVERSAL::DOES::does($object, "Treex::PML::Alt")
Truth table0%0/3
A and B
A= ref $objectB= UNIVERSAL::DOES::does($object, "Treex::PML::Alt")
ABresult
0X0
100
111
93 0 ▶ for (my $i=0; $i<@$object; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$object) 0 0 0
94 0 $am_decl->validate_object($object->[$i], {
95 flags => $flags,
96 path=> $path,
97 tag => "[".($i+1)."]",
98 log => $log,
99 });
100 }
101 } else {
102 0 $am_decl->validate_object($object,{
103 flags => $flags,
104 path=>$path,
105 # tag => "[1]", # TrEdNodeEdit would very much like [1] here
106 log => $log});
107 }
108 0 ▶ if ($opts and ref($opts->{log})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts and ref $opts->{"log"}) 0 0 0
Condition0%0/3
$opts and ref $opts->{"log"}
!ll&&!rl&&r
000
MC/DC0%0/2
$opts and ref $opts->{"log"}
$opts ref $opts->{"log"}
Truth table0%0/3
A and B
A= $optsB= ref $opts->{"log"}
ABresult
0X0
100
111
109 0 push @{$opts->{log}}, @$log;
110 }
111 0 ▶ return @$log ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
@$log ? : 0 0 0
112 }
113  
114  
115 9 1;
116 __END__
« PML/Backend/TrXML.pm ↑ Summary PML/Schema/Import.pm »