| 1 | package Rose::HTML::Object::MakeMethods::Generic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 43 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 43 | ▶ | use Carp(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 43 | ▶ | use base 'Rose::Object::MakeMethods'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 43 | our $VERSION = '0.606'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | sub array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 500 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
array: called CC=16 SCAR=35.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 500 | my($class, $name, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 500 | require Rose::HTML::Text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 500 | my %methods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 500 | ▶ | my $key = $args->{'hash_key'} || $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args->{'hash_key'} || $name
MC/DC0%0/2
$args->{'hash_key'} || $name
$args->{'hash_key'}
$name
Truth table66%2/3
A || B
A= $args->{'hash_key'}B= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 500 | ▶ | my $interface = $args->{'interface'} || 'get_set'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args->{'interface'} || 'get_set'
MC/DC100%1/1
$args->{'interface'} || 'get_set'
$args->{'interface'}
Truth table100%2/2
A
A= $args->{'interface'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | #unless($class->can('parent')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | #{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # $methods{'parent'} = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # my($self) = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # return Scalar::Util::weaken($self->{'parent'} = shift) if(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # return $self->{'parent'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 500 | ▶ | if($interface eq 'get_set_init') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my $init_method = $args->{'init_method'} || "init_$name"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'init_method'} || "init_$name"
MC/DC0%0/1
$args->{'init_method'} || "init_$name"
$args->{'init_method'}
Truth table0%0/2
A
A= $args->{'init_method'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | $methods{$name} = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # If called with no arguments, return array contents | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | unless(@_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $self->{$key} = $self->$init_method() unless(defined $self->{$key}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | return wantarray ? @{$self->{$key} ||= []} : $self->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{$key} ||= []
MC/DC0%0/1
$self->{$key} ||= []
$self->{$key}
Truth table0%0/2
A
A= $self->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # If called with a array ref, set new value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if(@_ == 1 && ref $_[0] eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 1 and ref $_[0] eq "ARRAY"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1
ref $_[0] eq "ARRAY"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $self->{$key} = [ map { _coerce_html_object($self, $_) } @{$_[0]} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $self->{$key} = [ map { _coerce_html_object($self, $_) } @_ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | return wantarray ? @{$self->{$key}} : $self->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | elsif($interface eq 'get_set_inited') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | $methods{$name} = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2630 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2630 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # If called with no arguments, return array contents | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2630 | ▶ | unless(@_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2180 | ▶ | $self->{$key} = [] unless(defined $self->{$key}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2180 | ▶ | return wantarray ? @{$self->{$key}} : $self->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # If called with a array ref, set new value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 450 | ▶ | if(@_ == 1 && ref $_[0] eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ == 1 and ref $_[0] eq "ARRAY"
MC/DC100%2/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1
ref $_[0] eq "ARRAY"
Truth table100%3/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 8 | $self->{$key} = [ map { _coerce_html_object($self, $_) } @{$_[0]} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 442 | $self->{$key} = [ map { _coerce_html_object($self, $_) } @_ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | return wantarray ? @{$self->{$key}} : $self->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 43 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | elsif($interface eq 'get_set_item') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | $methods{$name} = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | Carp::croak "Missing array index" unless(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if(@_ == 2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | return $self->{$key}[$_[0]] = _coerce_html_object($self, $_[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | return $self->{$key}[$_[0]] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | elsif($interface eq 'get_item') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | $methods{$name} = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 7 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 7 | ▶ | Carp::croak "Missing array index" unless(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 7 | return $self->{$key}[$_[0]]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 43 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | elsif($interface eq 'delete_item') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | $methods{$name} = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | ▶ | Carp::croak "Missing array index" unless(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 43 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | ▶ | splice(@{$self->{$key} || []}, $_[0], 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{$key} || []
MC/DC0%0/1
$self->{$key} || []
$self->{$key}
Truth table50%1/2
A
A= $self->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 43 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | elsif($interface eq 'unshift') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | $methods{$name} = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 3 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 3 | ▶ | Carp::croak "Missing value(s) to add" unless(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | unshift(@{$self->{$key} ||= []}, map { _coerce_html_object($self, $_) } (@_ == 1 && ref $_[0] eq 'ARRAY') ? @{$_[0]} : @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$self->{$key} ||= []
@_ == 1 and ref $_[0] eq "ARRAY"
MC/DC100%1/1
$self->{$key} ||= []
$self->{$key}
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1
ref $_[0] eq "ARRAY"
Truth table100%2/2
A
A= $self->{$key}
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 69 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | elsif($interface eq 'shift') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | $methods{$name} = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=18.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 3 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | ▶ | return splice(@{$self->{$key} ||= []}, 0, $_[0]) if(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->{$key} ||= []
MC/DC0%0/1
$self->{$key} ||= []
$self->{$key}
Truth table50%1/2
A
A= $self->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | return shift(@{$self->{$key} ||= []}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{$key} ||= []
MC/DC0%0/1
$self->{$key} ||= []
$self->{$key}
Truth table0%0/2
A
A= $self->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 69 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | elsif($interface eq 'clear') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | $methods{$name} = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 3 | $_[0]->{$key} = [] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 69 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | elsif($interface eq 'reset') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | $methods{$name} = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $_[0]->{$key} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | elsif($interface =~ /^(?:push|add)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | $methods{$name} = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 8 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 8 | ▶ | Carp::croak "Missing value(s) to add" unless(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | push(@{$self->{$key} ||= []}, map { _coerce_html_object($self, $_) } (@_ == 1 && ref $_[0] && ref $_[0] eq 'ARRAY') ? @{$_[0]} : @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition87%7/8
$self->{$key} ||= []
@_ == 1 and ref $_[0] and ref $_[0] eq "ARRAY"
@_ == 1 and ref $_[0]
MC/DC100%1/1
$self->{$key} ||= []
$self->{$key}
MC/DC0%0/3
@_ == 1 and ref $_[0] and ref $_[0] eq "ARRAY"
@_ == 1
ref $_[0]
ref $_[0] eq "ARRAY"
Truth table100%2/2
A
A= $self->{$key}
Truth table75%3/4
A and B and C
A= @_ == 1B= ref $_[0]C= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 69 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | elsif($interface eq 'pop') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | $methods{$name} = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=18.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 5 | ▶ | if(@_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 5 | ▶ | my $a = $self->{$key} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{$key} ||= []
MC/DC0%0/1
$self->{$key} ||= []
$self->{$key}
Truth table50%1/2
A
A= $self->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 5 | my $offset = @$a - $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 5 | ▶ | return splice(@$a, $offset < 0 ? 0 : $offset) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | return pop(@{$self->{$key} ||= []}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{$key} ||= []
MC/DC0%0/1
$self->{$key} ||= []
$self->{$key}
Truth table0%0/2
A
A= $self->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 69 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | elsif($interface eq 'get_set') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | $methods{$name} = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2404 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=31.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2404 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # If called with no arguments, return array contents | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 2404 | ▶ | unless(@_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 2404 | ▶ | return wantarray ? (defined $self->{$key} ? @{$self->{$key}} : ()) : $self->{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # If called with a array ref, set new value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if(@_ == 1 && ref $_[0] eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 1 and ref $_[0] eq "ARRAY"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1
ref $_[0] eq "ARRAY"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $self->{$key} = [ map { _coerce_html_object($self, $_) } @{$_[0]} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $self->{$key} = [ map { _coerce_html_object($self, $_) } @_ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | return wantarray ? @{$self->{$key}} : $self->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 26 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | else { Carp::croak "Unknown interface: $interface" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 500 | return \%methods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | sub _coerce_html_object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 463 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_coerce_html_object: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 463 | my($self, $arg) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 463 | ▶ | if(!ref $arg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 35 | return Rose::HTML::Text->new(text => $arg, parent => $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | elsif(!$arg->isa('Rose::HTML::Object')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | return Rose::HTML::Text->new(text => $arg, parent => $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 428 | $arg->parent($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 428 | return $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 43 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||