Flow/Results.pm

filter: Statementstmt 89.4% 17 / 19 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 50.0% 1 / 2 totaltotal 77.4% 24 / 31 CC 2 SCAR 8.0
CC
2
Cov
81%
success
6.0
__ANON__
2.0
BEGIN
1.0
CRAP 2.2
« Flow.pm ↑ Summary Flow/Result.pm »
1 package Regexp::Flow::Results;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Regexp::Flow::Results - contains Regexp::Flow::Result objects
9  
10 =head1 DESCRIPTION
11  
12 The purpose of this class is to act as a container for
13 C<Regexp::Flow::Result> objects. The reason it is not a simple arrayref
14 is that is is convenient to be able to consider its boolean and integer
15 value, just like the result of C<m///>.
16  
17 =head1 OVERLOADING
18  
19 It can be treated as a plain arrayref, in which case it accesses its
20 contents.
21  
22 It can be treated as a boolean or integer, in which cases it returns
23 the number of matches in the contents.
24  
25 =cut
26  
27 use overload
28 1 ▶ '0+' => \&count,
Subroutine BEGIN: called CC=1 SCAR=0.2
29 0 ▶ '@{}' => sub {shift->contents}, #~ not sure why, but \&contents dies
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 1 nomethod => \&count
31 1 ;
32 =head3 METHODS
33  
34 =cut
35  
36 =head3 contents
37  
38 An arrayref, empty by default, but which will contain information on
39 each successful match, as C<Regexp::Flow::Result> objects.
40  
41 =cut
42  
43 has contents => (
44 is => 'rw',
45 4 ▶ default => sub {[]},
Subroutine __ANON__: called CC=1 SCAR=0.0
46 1 );
47  
48 =head3 count
49  
50 A utility function which returns the number of successful matches.
51  
52 To be determined: does this inspect them for success?
53  
54 =cut
55  
56 4 ▶sub count {
Subroutine count: called CC=1 SCAR=0.0
Pod documented
57 4 return scalar @{shift->contents};
58 }
59  
60 =head3 succes
61  
62 A utility function which returns true or false depending on whether
63 there were successful matches.
64  
65 To be determined: does this inspect them for success?
66  
67 =cut
68  
69 0 ▶sub success {
Subroutine success: not called CC=2 SCAR=17.9
Pod undocumented
70 0 ▶ return shift->count ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
(shift())->count ? : 0 0 0
71 }
72  
73 =head1 SEE ALSO
74  
75 Regexp::Flow - which uses this module
76 (also for author and copyright information)
77  
78 =cut
79  
80 1 1;
81  
« Flow.pm ↑ Summary Flow/Result.pm »