Param/Compound.pm

filter: Statementstmt 24.5% 13 / 53 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 36.3% 4 / 11 Podpod 85.7% 6 / 7 totaltotal 27.0% 23 / 85 CC 13 SCAR 25.5
CC
13
Cov
19%
get
30.0
remove
20.0
new
6.0
CRAP 12.8
↑ Summary Param/Base.pm »
1 package Class::Param::Compound;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base 'Class::Param::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Params::Validate qw[];
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
10 0 ▶ my $class = ref $_[0] ? ref shift : shift;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
11 0 my $params = Params::Validate::validate_with(
12 params => \@_,
13 spec => [
14 (
15 {
16 type => Params::Validate::OBJECT,
17 isa => 'Class::Param::Base',
18 optional => 0
19 }
20 ) x @_
21 ],
22 called => "$class\::new"
23 );
24  
25 0 return bless( $params, $class );
26 }
27  
28 0 ▶sub params {
Subroutine params: not called CC=2 SCAR=17.9
Pod undocumented
29 0 ▶ return wantarray ? @{ $_[0] } : [ @{ $_[0] } ];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
30 }
31  
32 0 ▶sub get {
Subroutine get: not called CC=5 SCAR=34.0
Pod documented
33 0 my ( $self, $name ) = @_;
34  
35 0 my @values = ();
36  
37 0 foreach my $param ( $self->params ) {
38  
39 0 ▶ next unless $param->has($name);
Branch: 1 branch
BranchTrueFalseTotal
unless $param->has($name) 0 0 0
40  
41 0 my $value = $param->get($name);
42  
43 0 ▶ if ( ref $value eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'ARRAY') { } 0 0 0
44 0 push @values, @{ $value };
45 }
46 else {
47 0 push @values, $value;
48 }
49 }
50  
51 0 ▶ return @values > 1 ? \@values : $values[0];
Branch: 1 branch
BranchTrueFalseTotal
@values > 1 ? : 0 0 0
52 }
53  
54 0 ▶sub set {
Subroutine set: not called CC=2 SCAR=17.9
Pod documented
55 0 my ( $self, $name, $value ) = @_;
56  
57 0 foreach my $param ( $self->params ) {
58 0 $param->set( $name => $value );
59 }
60  
61 0 return 1;
62 }
63  
64 0 ▶sub clear {
Subroutine clear: not called CC=2 SCAR=17.9
Pod documented
65 0 my $self = shift;
66  
67 0 foreach my $param ( $self->params ) {
68 0 $param->clear;
69 }
70  
71 0 return 1;
72 }
73  
74 0 ▶sub remove {
Subroutine remove: not called CC=4 SCAR=30.0
Pod documented
75 0 my ( $self, $name ) = @_;
76  
77 0 my @removed = ();
78  
79 0 foreach my $param ( $self->params ) {
80  
81 0 my $value = $param->remove($name);
82  
83 0 ▶ if ( ref $value eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'ARRAY') { } 0 0 0
84 0 push @removed, @{ $value };
85 }
86 else {
87 0 push @removed, $value;
88 }
89 }
90  
91 0 ▶ return @removed > 1 ? \@removed : $removed[0];
Branch: 1 branch
BranchTrueFalseTotal
@removed > 1 ? : 0 0 0
92 }
93  
94 0 ▶sub names {
Subroutine names: not called CC=2 SCAR=17.9
Pod documented
95 0 my $self = shift;
96  
97 0 my %seen = ();
98 0 my @names = ();
99  
100 0 foreach my $param ( $self->params ) {
101 0 push @names, $param->names;
102 }
103  
104 0 return grep { $seen{$_}++ == 0 } @names;
105 }
106  
107 1 1;
108  
109 __END__
↑ Summary Param/Base.pm »