| 1 | package Class::Accessor; | ||||||||||||||||||||||||||||||||
| 2 | 6 | require 5.00502; | |||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 6 | $Class::Accessor::VERSION = '0.51'; | |||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 11 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||
| 7 | return bless | ||||||||||||||||||||||||||||||||
| 8 | defined $_[1] | ||||||||||||||||||||||||||||||||
| 9 | 11 | ▶ | ? {%{$_[1]}} # make a copy of $fields. | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||
| 10 | : {}, | ||||||||||||||||||||||||||||||||
| 11 | ref $_[0] || $_[0]; | ||||||||||||||||||||||||||||||||
| 12 | } | ||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | 13 | ▶ | sub mk_accessors { | ||||||||||||||||||||||||||||||
|
Subroutine
mk_accessors: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 15 | 13 | my($self, @fields) = @_; | |||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 13 | $self->_mk_accessors('rw', @fields); | |||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 6 | ▶ | if (eval { require Sub::Name }) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 21 | 0 | Sub::Name->import; | |||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | { | ||||||||||||||||||||||||||||||||
| 25 | 6 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | sub import { | ||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 28 | 2 | my ($class, @what) = @_; | |||||||||||||||||||||||||||||||
| 29 | 2 | my $caller = caller; | |||||||||||||||||||||||||||||||
| 30 | 2 | for (@what) { | |||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | if (/^(?:antlers|moose-?like)$/i) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | *{"${caller}::has"} = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 33 | 5 | my ($f, %args) = @_; | |||||||||||||||||||||||||||||||
| 34 | 5 | ▶ | $caller->_mk_accessors(($args{is}||"rw"), $f); | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{'is'} || 'rw'
MC/DC100%1/1
$args{'is'} || 'rw'
$args{'is'}
Truth table100%2/2
A
A= $args{'is'}
| |||||||||||||||||||||||||||||||||
| 35 | 1 | }; | |||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | *{"${caller}::extends"} = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||
| 37 | 1 | @{"${caller}::ISA"} = @_; | |||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | unless (grep $_->can("_mk_accessors"), @_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 39 | 1 | push @{"${caller}::ISA"}, $class; | |||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||
| 41 | 1 | }; | |||||||||||||||||||||||||||||||
| 42 | # we'll use their @ISA as a default, in case it happens to be | ||||||||||||||||||||||||||||||||
| 43 | # set already | ||||||||||||||||||||||||||||||||
| 44 | 1 | &{"${caller}::extends"}(@{"${caller}::ISA"}); | |||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 3 | ▶ | sub follow_best_practice { | ||||||||||||||||||||||||||||||
|
Subroutine
follow_best_practice: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 50 | 3 | my($self) = @_; | |||||||||||||||||||||||||||||||
| 51 | 3 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||
| 52 | 3 | *{"${class}::accessor_name_for"} = \&best_practice_accessor_name_for; | |||||||||||||||||||||||||||||||
| 53 | 3 | *{"${class}::mutator_name_for"} = \&best_practice_mutator_name_for; | |||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | 38 | ▶ | sub _mk_accessors { | ||||||||||||||||||||||||||||||
|
Subroutine
_mk_accessors: called CC=23 SCAR=32.0
| |||||||||||||||||||||||||||||||||
| 57 | 38 | my($self, $access, @fields) = @_; | |||||||||||||||||||||||||||||||
| 58 | 38 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||
| 59 | 38 | ▶ | my $ra = $access eq 'rw' || $access eq 'ro'; | ||||||||||||||||||||||||||||||
|
Condition100%3/3
$access eq 'rw' || $access eq 'ro'
MC/DC100%2/2
$access eq 'rw' || $access eq 'ro'
$access eq 'rw'
$access eq 'ro'
Truth table100%3/3
A || B
A= $access eq 'rw'B= $access eq 'ro'
| |||||||||||||||||||||||||||||||||
| 60 | 38 | ▶ | my $wa = $access eq 'rw' || $access eq 'wo'; | ||||||||||||||||||||||||||||||
|
Condition100%3/3
$access eq 'rw' || $access eq 'wo'
MC/DC100%2/2
$access eq 'rw' || $access eq 'wo'
$access eq 'rw'
$access eq 'wo'
Truth table100%3/3
A || B
A= $access eq 'rw'B= $access eq 'wo'
| |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 38 | foreach my $field (@fields) { | |||||||||||||||||||||||||||||||
| 63 | 56 | my $accessor_name = $self->accessor_name_for($field); | |||||||||||||||||||||||||||||||
| 64 | 56 | my $mutator_name = $self->mutator_name_for($field); | |||||||||||||||||||||||||||||||
| 65 | 56 | ▶ | if( $accessor_name eq 'DESTROY' or $mutator_name eq 'DESTROY' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$accessor_name eq "DESTROY" or $mutator_name eq "DESTROY"
MC/DC50%1/2
$accessor_name eq "DESTROY" or $mutator_name eq "DESTROY"
$accessor_name eq "DESTROY"
$mutator_name eq "DESTROY"
Truth table66%2/3
A or B
A= $accessor_name eq "DESTROY"B= $mutator_name eq "DESTROY"
| |||||||||||||||||||||||||||||||||
| 66 | 4 | $self->_carp("Having a data accessor named DESTROY in '$class' is unwise."); | |||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | 56 | ▶ | if ($accessor_name eq $mutator_name) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 69 | 38 | my $accessor; | |||||||||||||||||||||||||||||||
| 70 | 38 | ▶ | if ($ra && $wa) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$ra and $wa
MC/DC100%2/2
$ra and $wa
$ra
$wa
Truth table100%3/3
A and B
A= $raB= $wa
| |||||||||||||||||||||||||||||||||
| 71 | 22 | $accessor = $self->make_accessor($field); | |||||||||||||||||||||||||||||||
| 72 | } elsif ($ra) { | ||||||||||||||||||||||||||||||||
| 73 | 8 | $accessor = $self->make_ro_accessor($field); | |||||||||||||||||||||||||||||||
| 74 | } else { | ||||||||||||||||||||||||||||||||
| 75 | 8 | $accessor = $self->make_wo_accessor($field); | |||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | 38 | my $fullname = "${class}::$accessor_name"; | |||||||||||||||||||||||||||||||
| 78 | 38 | my $subnamed = 0; | |||||||||||||||||||||||||||||||
| 79 | 38 | ▶ | unless (defined &{$fullname}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 80 | 32 | ▶ | subname($fullname, $accessor) if defined &subname; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 81 | 32 | $subnamed = 1; | |||||||||||||||||||||||||||||||
| 82 | 32 | *{$fullname} = $accessor; | |||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||
| 84 | 38 | ▶ | if ($accessor_name eq $field) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 85 | # the old behaviour | ||||||||||||||||||||||||||||||||
| 86 | 38 | my $alias = "${class}::_${field}_accessor"; | |||||||||||||||||||||||||||||||
| 87 | 38 | ▶ | subname($alias, $accessor) if defined &subname and not $subnamed; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &Class::Accessor::subname and not $subnamed
MC/DC0%0/2
defined &Class::Accessor::subname and not $subnamed
defined &Class::Accessor::subname
not $subnamed
Truth table33%1/3
A and not(B)
A= defined &Class::Accessor::subnameB= not $subnamed
| |||||||||||||||||||||||||||||||||
| 88 | 38 | ▶ | *{$alias} = $accessor unless defined &{$alias}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | } else { | ||||||||||||||||||||||||||||||||
| 91 | 18 | my $fullaccname = "${class}::$accessor_name"; | |||||||||||||||||||||||||||||||
| 92 | 18 | my $fullmutname = "${class}::$mutator_name"; | |||||||||||||||||||||||||||||||
| 93 | 18 | ▶ | if ($ra and not defined &{$fullaccname}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ra and not defined &{$fullaccname;}
MC/DC50%1/2
$ra and not defined &{$fullaccname;}
$ra
not defined &{$fullaccname;}
Truth table66%2/3
A and not(B)
A= $raB= not defined &{$fullaccname;}
| |||||||||||||||||||||||||||||||||
| 94 | 12 | my $accessor = $self->make_ro_accessor($field); | |||||||||||||||||||||||||||||||
| 95 | 12 | ▶ | subname($fullaccname, $accessor) if defined &subname; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | 12 | *{$fullaccname} = $accessor; | |||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | 18 | ▶ | if ($wa and not defined &{$fullmutname}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$wa and not defined &{$fullmutname;}
MC/DC50%1/2
$wa and not defined &{$fullmutname;}
$wa
not defined &{$fullmutname;}
Truth table66%2/3
A and not(B)
A= $waB= not defined &{$fullmutname;}
| |||||||||||||||||||||||||||||||||
| 99 | 12 | my $mutator = $self->make_wo_accessor($field); | |||||||||||||||||||||||||||||||
| 100 | 12 | ▶ | subname($fullmutname, $mutator) if defined &subname; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 101 | 12 | *{$fullmutname} = $mutator; | |||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 6 | ▶ | sub mk_ro_accessors { | ||||||||||||||||||||||||||||||
|
Subroutine
mk_ro_accessors: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 110 | 10 | my($self, @fields) = @_; | |||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||
| 112 | 10 | $self->_mk_accessors('ro', @fields); | |||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||
| 115 | 10 | ▶ | sub mk_wo_accessors { | ||||||||||||||||||||||||||||||
|
Subroutine
mk_wo_accessors: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 116 | 10 | my($self, @fields) = @_; | |||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | 10 | $self->_mk_accessors('wo', @fields); | |||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | 9 | ▶ | sub best_practice_accessor_name_for { | ||||||||||||||||||||||||||||||
|
Subroutine
best_practice_accessor_name_for: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 122 | 9 | my ($class, $field) = @_; | |||||||||||||||||||||||||||||||
| 123 | 9 | return "get_$field"; | |||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | 9 | ▶ | sub best_practice_mutator_name_for { | ||||||||||||||||||||||||||||||
|
Subroutine
best_practice_mutator_name_for: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 127 | 9 | my ($class, $field) = @_; | |||||||||||||||||||||||||||||||
| 128 | 9 | return "set_$field"; | |||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||
| 131 | 38 | ▶ | sub accessor_name_for { | ||||||||||||||||||||||||||||||
|
Subroutine
accessor_name_for: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 132 | 38 | my ($class, $field) = @_; | |||||||||||||||||||||||||||||||
| 133 | 38 | return $field; | |||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | 38 | ▶ | sub mutator_name_for { | ||||||||||||||||||||||||||||||
|
Subroutine
mutator_name_for: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 137 | 38 | my ($class, $field) = @_; | |||||||||||||||||||||||||||||||
| 138 | 38 | return $field; | |||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | 11 | ▶ | sub set { | ||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 142 | 11 | my($self, $key) = splice(@_, 0, 2); | |||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | 11 | ▶ | if(@_ == 1) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 145 | 9 | $self->{$key} = $_[0]; | |||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||
| 147 | elsif(@_ > 1) { | ||||||||||||||||||||||||||||||||
| 148 | 2 | $self->{$key} = [@_]; | |||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||
| 150 | else { | ||||||||||||||||||||||||||||||||
| 151 | 0 | $self->_croak("Wrong number of arguments received"); | |||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||
| 155 | 19 | ▶ | sub get { | ||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=3 SCAR=16.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 156 | 19 | my $self = shift; | |||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | 19 | ▶ | if(@_ == 1) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 159 | 19 | return $self->{$_[0]}; | |||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||
| 161 | elsif( @_ > 1 ) { | ||||||||||||||||||||||||||||||||
| 162 | 0 | return @{$self}{@_}; | |||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||
| 164 | else { | ||||||||||||||||||||||||||||||||
| 165 | 0 | $self->_croak("Wrong number of arguments received"); | |||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||
| 169 | 10 | ▶ | sub make_accessor { | ||||||||||||||||||||||||||||||
|
Subroutine
make_accessor: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 170 | 10 | my ($class, $field) = @_; | |||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||
| 172 | 16 | ▶ | return sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 173 | 16 | my $self = shift; | |||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | 16 | ▶ | if(@_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 176 | 5 | return $self->set($field, @_); | |||||||||||||||||||||||||||||||
| 177 | } else { | ||||||||||||||||||||||||||||||||
| 178 | 11 | return $self->get($field); | |||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||
| 180 | 10 | }; | |||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | 7 | ▶ | sub make_ro_accessor { | ||||||||||||||||||||||||||||||
|
Subroutine
make_ro_accessor: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 184 | 7 | my($class, $field) = @_; | |||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||
| 186 | 8 | ▶ | return sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 187 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||
| 189 | 8 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 190 | 2 | my $caller = caller; | |||||||||||||||||||||||||||||||
| 191 | 2 | $self->_croak("'$caller' cannot alter the value of '$field' on objects of class '$class'"); | |||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||
| 193 | else { | ||||||||||||||||||||||||||||||||
| 194 | 6 | return $self->get($field); | |||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||
| 196 | 7 | }; | |||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||
| 199 | 7 | ▶ | sub make_wo_accessor { | ||||||||||||||||||||||||||||||
|
Subroutine
make_wo_accessor: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 200 | 7 | my($class, $field) = @_; | |||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||
| 202 | 7 | ▶ | return sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 203 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||
| 205 | 7 | ▶ | unless (@_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 206 | 2 | my $caller = caller; | |||||||||||||||||||||||||||||||
| 207 | 2 | $self->_croak("'$caller' cannot access the value of '$field' on objects of class '$class'"); | |||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||
| 209 | else { | ||||||||||||||||||||||||||||||||
| 210 | 5 | return $self->set($field, @_); | |||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||
| 212 | 7 | }; | |||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||
| 216 | 6 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||
| 218 | 4 | ▶ | sub _carp { | ||||||||||||||||||||||||||||||
|
Subroutine
_carp: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||
| 219 | 4 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||
| 220 | 4 | ▶ | Carp::carp($msg || $self); | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$msg || $self
MC/DC0%0/2
$msg || $self
$msg
$self
Truth table33%1/3
A || B
A= $msgB= $self
| |||||||||||||||||||||||||||||||||
| 221 | 4 | return; | |||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||
| 224 | 8 | ▶ | sub _croak { | ||||||||||||||||||||||||||||||
|
Subroutine
_croak: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||||||
| 225 | 8 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||
| 226 | 8 | ▶ | Carp::croak($msg || $self); | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$msg || $self
MC/DC0%0/2
$msg || $self
$msg
$self
Truth table33%1/3
A || B
A= $msgB= $self
| |||||||||||||||||||||||||||||||||
| 227 | 0 | return; | |||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||
| 230 | 6 | 1; | |||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||
| 232 | __END__ | ||||||||||||||||||||||||||||||||