PML/Schema/Constant.pm

filter: Statementstmt 57.7% 26 / 45 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 58.8% 10 / 17 Podpod 77.7% 7 / 9 totaltotal 48.3% 43 / 89 CC 7 SCAR 25.1
CC
7
Cov
44%
validate_object
42.0
serialize_get_children
6.0
is_atomic
2.0
CRAP 12.3
« PML/Backend/FS.pm ↑ Summary PML/List.pm »
1 package Treex::PML::Schema::Constant;
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::Constant - implements constant declaration.
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_CONSTANT_DECL.
33  
34 =item $decl->get_decl_type_str ()
35  
36 Returns the string 'constant'.
37  
38 =item $decl->get_value ()
39  
40 Return the constant value.
41  
42 =item $decl->get_values ()
43  
44 Returns a singleton list consisting of the constant value (for
45 compatibility with choice declarations).
46  
47 =item $decl->is_atomic ()
48  
49 Returns 1.
50  
51 =item $decl->get_content_decl ()
52  
53 Returns undef.
54  
55  
56  
57 =back
58  
59 =cut
60  
61  
62 0 ▶sub is_atomic { 1 }
Subroutine is_atomic: not called CC=1 SCAR=6.9
Pod documented
63 16 ▶sub get_decl_type { return PML_CONSTANT_DECL; }
Subroutine get_decl_type: called CC=1 SCAR=0.0
Pod documented
64 0 ▶sub get_decl_type_str { return 'constant'; }
Subroutine get_decl_type_str: not called CC=1 SCAR=6.9
Pod documented
65 0 ▶sub get_content_decl { return(undef); }
Subroutine get_content_decl: not called CC=1 SCAR=6.9
Pod documented
66 0 ▶sub get_value { return $_[0]->{value}; }
Subroutine get_value: not called CC=1 SCAR=6.9
Pod documented
67 0 ▶sub get_values { my @val=($_[0]->{value}); return @val; }
Subroutine get_values: not called CC=1 SCAR=6.9
Pod documented
68 2 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
69 2 my ($self,$opts)=@_;
70 2 $self->{-parent}{-decl} = 'constant';
71 }
72  
73 0 ▶sub validate_object {
Subroutine validate_object: not called CC=6 SCAR=37.4
Pod documented
74 0 my ($self, $object, $opts) = @_;
75 0 my $const = $self->{value};
76 0 ▶ my $ok = ($object eq $const) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$object eq $const ? : 0 0 0
77 0 ▶ if (!$ok and ref($opts) and ref($opts->{log})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ok and ref $opts and ref $opts->{"log"}) 0 0 0
Condition0%0/6
not $ok and ref $opts and ref $opts->{"log"}
!ll&&!rl&&r
000
not $ok and ref $opts
!ll&&!rl&&r
000
MC/DC0%0/3
not $ok and ref $opts and ref $opts->{"log"}
not $ok ref $opts ref $opts->{"log"}
Truth table0%0/4
not(A) and B and C
A= not $okB= ref $optsC= ref $opts->{"log"}
ABCresult
0XX0
10X0
1100
1111
78 0 my $path = $opts->{path};
79 0 my $tag = $opts->{tag};
80 0 ▶ $path.="/".$tag if $tag ne q{};
Branch: 1 branch
BranchTrueFalseTotal
if $tag ne "" 0 0 0
81 0 push @{$opts->{log}}, "$path: invalid constant, should be '$const', got: '$object'";
82 }
83 0 return $ok;
84 }
85  
86 0 ▶sub serialize_get_children {
Subroutine serialize_get_children: not called CC=2 SCAR=17.9
Pod undocumented
87 0 my ($self,$opts)=@_;
88 0 ▶ my $writer = $opts->{writer} || croak __PACKAGE__."->serialize: missing required option 'writer'!\n";
Condition0%0/2
$opts->{'writer'} || croak("Treex::PML::Schema::Constant->serialize: missing required option 'writer'!\n")
l!l
00
MC/DC0%0/1
$opts->{'writer'} || croak("Treex::PML::Schema::Constant->serialize: missing required option 'writer'!\n")
$opts->{'writer'}
Truth table0%0/2
A
A= $opts->{'writer'}
Aresult
11
00
89 0 return [undef, $self->{value}];
90 }
91  
92 9 1;
93 __END__
« PML/Backend/FS.pm ↑ Summary PML/List.pm »