Pad/Result.pm

filter: Statementstmt 91.3% 42 / 46 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 80.0% 4 / 5 totaltotal 89.8% 62 / 69 CC 6 SCAR 8.3
CC
6
Cov
89%
reservesReader
4.0
help
2.2
version
2.2
CRAP 2.3
« Pad/Type/Temporal.pm ↑ Summary Pad/Type/Duration.pm »
1 12 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 12 ▶use Object::Pad qw(:experimental(mop));
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 class Getopt::Pad::Result {
5 # Carp is called fully qualified: an imported croak would be a method
6 # of every Result and reserve its name for no reason.
7 12 ▶ use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 12 our $VERSION = '0.06';
10  
11 # Names Perl looks up on an object by itself; a Reader by one of these
12 # would run at the wrong time with the wrong arguments.
13 12 my %isPerlHook = map { $_ => 1 } qw(DESTROY AUTOLOAD);
14  
15 field $command :param :reader = undef;
16 6 ▶ field $subcommand :param :reader = undef;
Subroutine command: called CC=1 SCAR=0.0
Pod documented
17 30 ▶ field $helper :param = undef;
Subroutine subcommand: called CC=1 SCAR=0.0
Pod documented
18  
19 # Whether a Reader named $name would clash with what every Result
20 # already answers to: a method (including the ones Object::Pad and
21 # UNIVERSAL provide), a constructor param, or a Perl hook. Derived from
22 # the class itself, so nothing here can drift from it.
23 611 ▶ method reservesReader :common ($name) {
Subroutine reservesReader: called CC=4 SCAR=13.9
Pod undocumented
24 611 ▶ return 1 if $isPerlHook{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $isPerlHook{$name} 3 608 611
25 608 ▶ return 1 if $class->can($name);
Branch: 1 branch
BranchTrueFalseTotal
if $class->can($name) 11 597 608
26 597 my @params = map { $_->get_attribute_value('param') } grep { $_->has_attribute('param') } Object::Pad::MOP::Class->for_class($class)->fields;
27 597 ▶ return (grep { $_ eq $name } @params) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
grep({$_ eq $name;} @params) ? : 2 595 597
28 12 }
29  
30 1 ▶ method help() {
Subroutine help: called CC=2 SCAR=7.9
Pod documented
31 1 ▶ Carp::croak('Getopt::Pad: no help renderer attached to this result') unless defined $helper;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $helper 1 0 1
32 0 $helper->printHelp;
33 0 exit 0;
34 12 }
35  
36 1 ▶ method version() {
Subroutine version: called CC=2 SCAR=7.9
Pod documented
37 1 ▶ Carp::croak('Getopt::Pad: no help renderer attached to this result') unless defined $helper;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $helper 1 0 1
38 0 $helper->printVersion;
39 0 exit 0;
40 12 }
41 }
42  
43 12 1;
44  
45 __END__
« Pad/Type/Temporal.pm ↑ Summary Pad/Type/Duration.pm »