FindApp/Object/State/Group/State.pm

filter: Statementstmt 72.2% 86 / 119 Branchbran 40.4% 17 / 42 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 80.6% 25 / 31 Podpod 100% 12 / 12 totaltotal 65.8% 141 / 214 CC 26 SCAR 18.2
CC
26
Cov
62%
name
17.1
name
17.1
access_AWF_subdir
6.0
CRAP 6.2
« FindApp/Utils/Objects.pm ↑ Summary FindApp/Utils/Assert.pm »
1 package FindApp::Object::State::Group::State;
2  
3 6 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use mro "c3";
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 ▶use FindApp::Vars qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use FindApp::Utils qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 #################################################################
12  
13 sub dir_field ( _ ) ;
14 sub dir_fields ( ) ;
15 sub dir_types ( ) ;
16 sub field_map ( & @ ) ;
17 sub type_map ( & @ ) ;
18  
19 #################################################################
20  
21 12 ▶sub dir_types() {
Subroutine dir_types: called CC=1 SCAR=0.0
22 12 return qw(allowed wanted found);
23 }
24  
25 18 ▶sub dir_field(_) {
Subroutine dir_field: called CC=1 SCAR=0.0
26 18 my($type) = @_;
27 6 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
28 18 return &{uc $type};
29 }
30  
31 12 ▶sub type_map(&@) {
Subroutine type_map: called CC=1 SCAR=0.0
32 12 my $code = shift;
33 12 return map { &$code } +dir_types, @_;
34 }
35  
36 sub dir_fields() {
37 my $fields = [ type_map{dir_field} ];
38 return @$fields;
39 }
40  
41 sub field_map(&@) {
42 my $code = shift;
43 return map { &$code } +dir_fields, @_;
44 }
45  
46 6 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 ################################################################
49  
50 6 ▶use pluskeys qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
51 NAME
52 EXPORTED
53 6 ▶} => type_map{uc};
Subroutine __ANON__: called CC=1 SCAR=0.0
54  
55 56 ▶sub unexported {
Subroutine unexported: called CC=3 SCAR=15.0
Pod documented
56 56 ▶ bad_args(!@_ || @_ > 2);
Subroutine unexported: not called CC=3 SCAR=15.0
Pod documented
Condition16%1/6
!@_ || @_ > 2
l!l&&r!l&&!r
0056
!@_ || @_ > 2
l!l&&r!l&&!r
000
MC/DC0%0/2
!@_ || @_ > 2
!@_ @_ > 2
MC/DC0%0/2
!@_ || @_ > 2
!@_ @_ > 2
Truth table33%1/3
not(A) || B
A= !@_B= @_ > 2
ABresult
1X1
011
000
Truth table0%0/3
not(A) || B
A= !@_B= @_ > 2
ABresult
1X1
011
000
57 56 my($self, $value) = @_;
58 0 ▶ if ($value) {
Branch: 2 branches
BranchTrueFalseTotal
if ($value) 56 0 56
if ($value) 0 0 0
59 0 $$self{+EXPORTED} = 0;
60 }
61 0 return !$$self{+EXPORTED};
62 }
63  
64 14 ▶sub have_exported {
Subroutine have_exported: called CC=1 SCAR=1.2
Pod documented
65 0 ▶ good_args(@_ == 1);
Subroutine have_exported: not called CC=1 SCAR=1.2
Pod documented
66 0 my $self = shift;
67 0 return $$self{+EXPORTED};
68 }
69  
70 10 ▶sub bump_exports {
Subroutine bump_exports: called CC=1 SCAR=1.2
Pod documented
71 0 ▶ good_args(@_ == 1);
Subroutine bump_exports: not called CC=1 SCAR=1.2
Pod documented
72 0 my $self = shift;
73 0 return ++$$self{+EXPORTED};
74 }
75  
76 72 ▶sub exported {
Subroutine exported: called CC=2 SCAR=8.1
Pod documented
77 0 ▶ bad_args(@_ > 2);
Subroutine exported: not called CC=2 SCAR=8.1
Pod documented
78 0 my $self = shift;
79 6 ▶ use warnings FATAL => qw(numeric uninitialized);
Subroutine BEGIN: called CC=1 SCAR=0.0
80 0 ▶ $$self{+EXPORTED} += shift if @_;
Branch: 2 branches
BranchTrueFalseTotal
if @_ 36 36 72
if @_ 0 0 0
81 0 $$self{+EXPORTED};
82 }
83  
84 274 ▶sub name {
Subroutine name: called CC=7 SCAR=28.4
Pod documented
85 0 ▶ bad_args(@_ > 2);
Subroutine name: not called CC=7 SCAR=28.4
Pod documented
86 0 my $self = shift;
87 0 ▶ return $$self{+NAME} unless @_;
Branch: 2 branches
BranchTrueFalseTotal
unless @_ 218 56 274
unless @_ 0 0 0
88 0 my $old_name = $$self{+NAME};
89 0 my $new_name = shift;
90 0 for ($new_name) {
91 0 ▶ defined || die "name cannot be undef";
Branch: 2 branches
BranchTrueFalseTotal
defined $_ or die "name cannot be undef" 56 0 56
defined $_ or die "name cannot be undef" 0 0 0
92 0 ▶ length || die "name cannot be zero length";
Branch: 2 branches
BranchTrueFalseTotal
length $_ or die "name cannot be zero length" 56 0 56
length $_ or die "name cannot be zero length" 0 0 0
93 0 ▶ !ref || die "name cannot be a reference";
Branch: 2 branches
BranchTrueFalseTotal
ref $_ and die "name cannot be a reference" 0 56 56
ref $_ and die "name cannot be a reference" 0 0 0
94 0 ▶ !/\0/ || die "name cannot contain NUL characters";
Branch: 2 branches
BranchTrueFalseTotal
/\0/ and die "name cannot contain NUL characters" 0 56 56
/\0/ and die "name cannot contain NUL characters" 0 0 0
95 }
96 0 $$self{+NAME} = $new_name;
97 0 return $old_name;
98 }
99  
100 472 ▶sub access_AWF_subdir {
Subroutine access_AWF_subdir: called CC=4 SCAR=17.9
Pod documented
101 0 ▶ my($self, $dirs, @values) = @_;
Subroutine access_AWF_subdir: not called CC=4 SCAR=17.9
Pod documented
102 0 ▶ $dirs->set(@values) if @values;
Branch: 2 branches
BranchTrueFalseTotal
if @values 80 392 472
if @values 0 0 0
103 0 ▶ if (wantarray) { return $dirs->get }
Branch: 4 branches
BranchTrueFalseTotal
if (wantarray) { } 76 396 472
elsif (defined wantarray) { } 310 86 396
if (wantarray) { } 0 0 0
elsif (defined wantarray) { } 0 0 0
104 0 elsif (defined wantarray) { return $dirs }
105 0 else { return }
106 }
107  
108 6 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.0
109 6 ▶ my %ACCESSOR = type_map { $_ => dir_field };
Subroutine __ANON__: called CC=1 SCAR=0.0
110 # BUILD: allowed, wanted, found
111 6 ▶ while (my($TYPE, $FIELD) = each %ACCESSOR) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %ACCESSOR) 18 6 24
112 0 ▶ function $TYPE => sub { &ENTER_TRACE_2;
Subroutine allowed: called CC=1 SCAR=0.1
Subroutine wanted: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.1
113 0 my $self = shift;
114 102 $self->access_AWF_subdir($$self{$FIELD}, @_);
115 18 };
116 }
117 }
118  
119 1 1;
120  
121 =encoding utf8
122  
123 =head1 NAME
124  
125 FindApp::Object::State::Group::Object::State - FIXME
126  
127 =head1 SYNOPSIS
128  
129 use FindApp::Object::State::Group::Object::State;
130  
131 =head1 DESCRIPTION
132  
133 =head2 Pluskey Attributes
134  
135 These are always private; use the methods insteads.
136  
137 =over
138  
139 =item ALLOWED
140  
141 =item EXPORTED
142  
143 =item FOUND
144  
145 =item NAME
146  
147 =item WANTED
148  
149 =back
150  
151 =head2 Public Methods
152  
153 =over
154  
155 =item ALLOWED
156  
157 =item FOUND
158  
159 =item WANTED
160  
161 =item access_AWF_subdir
162  
163 =item allowed
164  
165 =item bump_exports
166  
167 =item exported
168  
169 =item found
170  
171 =item have_exported
172  
173 =item name
174  
175 =item unexported
176  
177 =item wanted
178  
179 =item FIXME
180  
181 =back
182  
183 =head2 Exports
184  
185 =over
186  
187 =item FIXME
188  
189 =back
190  
191 =head1 EXAMPLES
192  
193 =head1 ENVIRONMENT
194  
195 =head1 SEE ALSO
196  
197 =over
198  
199 =item L<FindApp>
200  
201 =back
202  
203 =head1 CAVEATS AND PROVISOS
204  
205 =head1 BUGS AND LIMITATIONS
206  
207 =head1 HISTORY
208  
209 =head1 AUTHOR
210  
211 Tom Christiansen << <tchrist@perl.com> >>
212  
213 =head1 LICENCE AND COPYRIGHT
214  
215 Copyright (c) 2016, Tom Christiansen C<< <tchrist@perl.com> >>.
216 All Rights Reserved.
217  
218 This module is free software; you can redistribute it and/or
219 modify it under the same terms as Perl itself. See L<perlartistic>.
220  
221 =cut
222  
« FindApp/Utils/Objects.pm ↑ Summary FindApp/Utils/Assert.pm »