Pad/Result/Generator.pm

filter: Statementstmt 94.6% 71 / 75 Branchbran n/a Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 92.3% 24 / 26 Podpod 0.0% 0 / 2 totaltotal 89.8% 97 / 108 CC 3 SCAR 0.9
CC
3
Cov
94%
generate
2.0
mintClass
2.0
city
1.0
CRAP 1.1
« Pad/Spec/Arg.pm ↑ Summary Pad/Config/Format/Json.pm »
1 package Getopt::Pad::Result::Generator;
2  
3 9 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 ▶use Object::Pad qw(:experimental(mop));
Subroutine BEGIN: called CC=1 SCAR=0.0
9 9 ▶use Getopt::Pad::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 our $VERSION = '0.05';
12  
13 4 my $classCounter = 0;
14 4 my %classForReaders;
15  
16 93 ▶sub generate($level) {
Subroutine generate: called CC=2 SCAR=7.0
Pod undocumented
17 93 my @readers = sort map { $_->reader } $level->declaredOptions, $level->args;
18 93 my $cacheKey = join("\0", @readers);
19 93 ▶ return $classForReaders{$cacheKey} //= mintClass(@readers);
Condition66%2/3
$classForReaders{$cacheKey} //= mintClass(@readers)
l!l&&r!l&&!r
61320
MC/DC0%0/2
$classForReaders{$cacheKey} //= mintClass(@readers)
$classForReaders{$cacheKey} mintClass(@readers)
Truth table66%2/3
A //= B
A= $classForReaders{$cacheKey}B= mintClass(@readers)
ABresult
1X1
011
000
20 }
21  
22 32 ▶sub mintClass(@readers) {
Subroutine mintClass: called CC=2 SCAR=6.9
Pod undocumented
23 32 my $className = 'Getopt::Pad::Result::_' . ++$classCounter;
24 32 my $meta = Object::Pad::MOP::Class->create_class($className, isa => 'Getopt::Pad::Result');
25  
26 32 foreach my $reader (@readers) {
27 48 ▶ $meta->add_field('$' . $reader, param => $reader, default => undef, reader => $reader);
Subroutine input: called CC=1 SCAR=0.0
Subroutine inputs: called CC=1 SCAR=0.0
Subroutine only: not called CC=1 SCAR=0.0
Subroutine output: called CC=1 SCAR=0.0
Subroutine owner: called CC=1 SCAR=0.0
Subroutine source: called CC=1 SCAR=0.0
Subroutine sourceUrl: called CC=1 SCAR=0.0
Subroutine color: called CC=1 SCAR=0.0
Subroutine format: called CC=1 SCAR=0.0
Subroutine height: called CC=1 SCAR=0.0
Subroutine path: called CC=1 SCAR=0.0
Subroutine tag: called CC=1 SCAR=0.0
Subroutine title: called CC=1 SCAR=0.0
Subroutine title: called CC=1 SCAR=0.0
Subroutine verbose: called CC=1 SCAR=0.0
Subroutine verbose: called CC=1 SCAR=0.0
Subroutine width: called CC=1 SCAR=0.0
Subroutine city: not called CC=1 SCAR=0.0
28 }
29  
30 32 $meta->seal;
31 32 return $className;
32 }
33  
34 4 1;
35  
36 __END__
« Pad/Spec/Arg.pm ↑ Summary Pad/Config/Format/Json.pm »