| 1 | package MouseX::NativeTraits::MethodProvider::Str; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Mouse::Util::TypeConstraints (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | extends qw(MouseX::NativeTraits::MethodProvider); | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 10 | ▶ | sub generate_append { | ||||||||||||||||||||||||||
|
Subroutine
generate_append: called CC=1 SCAR=0.9
Pod
documented
| |||||||||||||||||||||||||||||
| 8 | 10 | my($self) = @_; | |||||||||||||||||||||||||||
| 9 | 10 | my $reader = $self->reader; | |||||||||||||||||||||||||||
| 10 | 10 | my $writer = $self->writer; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=15.1
Subroutine
append: called CC=3 SCAR=15.1
| |||||||||||||||||||||||||||||
| 13 | 0 | my($instance, $value) = @_; | |||||||||||||||||||||||||||
| 14 | 0 | ▶ | if(@_ != 2) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 15 | 0 | $self->argument_error('append', 2, 2, scalar @_); | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | 0 | ▶ | defined($value) or $self->meta->throw_error( | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 18 | "The argument passed to append must be a string"); | ||||||||||||||||||||||||||||
| 19 | 0 | $writer->( $instance, $reader->( $instance ) . $value ); | |||||||||||||||||||||||||||
| 20 | 10 | }; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 10 | ▶ | sub generate_prepend { | ||||||||||||||||||||||||||
|
Subroutine
generate_prepend: called CC=1 SCAR=0.1
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 10 | my($self) = @_; | |||||||||||||||||||||||||||
| 25 | 10 | my $reader = $self->reader; | |||||||||||||||||||||||||||
| 26 | 10 | my $writer = $self->writer; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 20 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||
| 29 | 20 | my($instance, $value) = @_; | |||||||||||||||||||||||||||
| 30 | 20 | ▶ | if(@_ != 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | $self->argument_error('prepend', 2, 2, scalar @_); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | 20 | ▶ | defined($value) or $self->meta->throw_error( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | "The argument passed to prepend must be a string"); | ||||||||||||||||||||||||||||
| 35 | 20 | $writer->( $instance, $value . $reader->( $instance ) ); | |||||||||||||||||||||||||||
| 36 | 10 | }; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 10 | ▶ | sub generate_replace { | ||||||||||||||||||||||||||
|
Subroutine
generate_replace: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 10 | my($self) = @_; | |||||||||||||||||||||||||||
| 41 | 10 | my $reader = $self->reader; | |||||||||||||||||||||||||||
| 42 | 10 | my $writer = $self->writer; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 70 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||
| 45 | 70 | my( $instance, $regexp, $replacement ) = @_; | |||||||||||||||||||||||||||
| 46 | 70 | ▶ | if(@_ != 3) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 0 | $self->argument_error('replace', 3, 3, scalar @_); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 70 | ▶ | ( Mouse::Util::TypeConstraints::Str($regexp) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
Mouse::Util::TypeConstraints::Str($regexp) or Mouse::Util::TypeConstraints::RegexpRef($regexp)
MC/DC100%2/2
Mouse::Util::TypeConstraints::Str($regexp) or Mouse::Util::TypeConstraints::RegexpRef($regexp)
Mouse::Util::TypeConstraints::Str($regexp)
Mouse::Util::TypeConstraints::RegexpRef($regexp)
Truth table100%3/3
A or B
A= Mouse::Util::TypeConstraints::Str($regexp)B= Mouse::Util::TypeConstraints::RegexpRef($regexp)
| |||||||||||||||||||||||||||||
| 50 | || Mouse::Util::TypeConstraints::RegexpRef($regexp) ) | ||||||||||||||||||||||||||||
| 51 | or $self->meta->throw_error( | ||||||||||||||||||||||||||||
| 52 | "The first argument passed to replace must be a string" | ||||||||||||||||||||||||||||
| 53 | . " or regexp reference"); | ||||||||||||||||||||||||||||
| 54 | 60 | my $v = $reader->( $instance ); | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 60 | ▶ | if ( ref($replacement) eq 'CODE' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 20 | $v =~ s/$regexp/$replacement->()/e; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | else { | ||||||||||||||||||||||||||||
| 60 | 40 | ▶ | Mouse::Util::TypeConstraints::Str($replacement) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | or $self->meta->throw_error( | ||||||||||||||||||||||||||||
| 62 | "The second argument passed to replace must be a string" | ||||||||||||||||||||||||||||
| 63 | . " or code reference"); | ||||||||||||||||||||||||||||
| 64 | 30 | $v =~ s/$regexp/$replacement/; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 50 | $writer->( $instance, $v ); | |||||||||||||||||||||||||||
| 68 | 10 | }; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub generate_replace_globally { | ||||||||||||||||||||||||||
|
Subroutine
generate_replace_globally: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 0 | my($self) = @_; | |||||||||||||||||||||||||||
| 73 | 0 | my $reader = $self->reader; | |||||||||||||||||||||||||||
| 74 | 0 | my $writer = $self->writer; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 77 | 0 | my( $instance, $regexp, $replacement ) = @_; | |||||||||||||||||||||||||||
| 78 | 0 | ▶ | if(@_ != 3) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | $self->argument_error('replace_globally', 3, 3, scalar @_); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | 0 | ▶ | ( Mouse::Util::TypeConstraints::Str($regexp) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Mouse::Util::TypeConstraints::Str($regexp) or Mouse::Util::TypeConstraints::RegexpRef($regexp)
MC/DC0%0/2
Mouse::Util::TypeConstraints::Str($regexp) or Mouse::Util::TypeConstraints::RegexpRef($regexp)
Mouse::Util::TypeConstraints::Str($regexp)
Mouse::Util::TypeConstraints::RegexpRef($regexp)
Truth table0%0/3
A or B
A= Mouse::Util::TypeConstraints::Str($regexp)B= Mouse::Util::TypeConstraints::RegexpRef($regexp)
| |||||||||||||||||||||||||||||
| 82 | || Mouse::Util::TypeConstraints::RegexpRef($regexp) ) | ||||||||||||||||||||||||||||
| 83 | or $self->meta->throw_error( | ||||||||||||||||||||||||||||
| 84 | "The first argument passed to replace_globally must be a string" | ||||||||||||||||||||||||||||
| 85 | . " or regexp reference"); | ||||||||||||||||||||||||||||
| 86 | 0 | my $v = $reader->( $instance ); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ( ref($replacement) eq 'CODE' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | $v =~ s/$regexp/$replacement->()/eg; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | else { | ||||||||||||||||||||||||||||
| 92 | 0 | ▶ | Mouse::Util::TypeConstraints::Str($replacement) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | or $self->meta->throw_error( | ||||||||||||||||||||||||||||
| 94 | "The second argument passed to replace must be a string" | ||||||||||||||||||||||||||||
| 95 | . " or code reference"); | ||||||||||||||||||||||||||||
| 96 | 0 | $v =~ s/$regexp/$replacement/g; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | $writer->( $instance, $v ); | |||||||||||||||||||||||||||
| 100 | 0 | }; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 10 | ▶ | sub generate_match { | ||||||||||||||||||||||||||
|
Subroutine
generate_match: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 104 | 10 | my($self) = @_; | |||||||||||||||||||||||||||
| 105 | 10 | my $reader = $self->reader; | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 80 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 108 | 80 | my($instance, $regexp) = @_; | |||||||||||||||||||||||||||
| 109 | 80 | ▶ | if(@_ != 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 10 | $self->argument_error('match', 2, 2, scalar @_); | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | 70 | ▶ | ( Mouse::Util::TypeConstraints::Str($regexp) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
Mouse::Util::TypeConstraints::Str($regexp) or Mouse::Util::TypeConstraints::RegexpRef($regexp)
MC/DC100%2/2
Mouse::Util::TypeConstraints::Str($regexp) or Mouse::Util::TypeConstraints::RegexpRef($regexp)
Mouse::Util::TypeConstraints::Str($regexp)
Mouse::Util::TypeConstraints::RegexpRef($regexp)
Truth table100%3/3
A or B
A= Mouse::Util::TypeConstraints::Str($regexp)B= Mouse::Util::TypeConstraints::RegexpRef($regexp)
| |||||||||||||||||||||||||||||
| 113 | || Mouse::Util::TypeConstraints::RegexpRef($regexp) ) | ||||||||||||||||||||||||||||
| 114 | or $self->meta->throw_error( | ||||||||||||||||||||||||||||
| 115 | "The argument passed to match must be a string" | ||||||||||||||||||||||||||||
| 116 | . " or regexp reference"); | ||||||||||||||||||||||||||||
| 117 | 60 | $reader->( $instance ) =~ $regexp; | |||||||||||||||||||||||||||
| 118 | 10 | }; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 5 | ▶ | sub generate_chop { | ||||||||||||||||||||||||||
|
Subroutine
generate_chop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 122 | 5 | my($self) = @_; | |||||||||||||||||||||||||||
| 123 | 5 | my $reader = $self->reader; | |||||||||||||||||||||||||||
| 124 | 5 | my $writer = $self->writer; | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 20 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 127 | 20 | my($instance) = @_; | |||||||||||||||||||||||||||
| 128 | 20 | ▶ | if(@_ != 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 10 | $self->argument_error('chop', 1, 1, scalar @_); | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | 10 | my $v = $reader->( $instance ); | |||||||||||||||||||||||||||
| 132 | 10 | my $r = chop($v); | |||||||||||||||||||||||||||
| 133 | 10 | $writer->( $instance, $v ); | |||||||||||||||||||||||||||
| 134 | 10 | return $r; | |||||||||||||||||||||||||||
| 135 | 5 | }; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 5 | ▶ | sub generate_chomp { | ||||||||||||||||||||||||||
|
Subroutine
generate_chomp: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 139 | 5 | my($self) = @_; | |||||||||||||||||||||||||||
| 140 | 5 | my $reader = $self->reader; | |||||||||||||||||||||||||||
| 141 | 5 | my $writer = $self->writer; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 30 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 144 | 30 | my($instance) = @_; | |||||||||||||||||||||||||||
| 145 | 30 | ▶ | if(@_ != 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 10 | $self->argument_error('chomp', 1, 1, scalar @_); | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | 20 | my $v = $reader->( $instance ); | |||||||||||||||||||||||||||
| 149 | 20 | my $r = chomp($v); | |||||||||||||||||||||||||||
| 150 | 20 | $writer->( $instance, $v ); | |||||||||||||||||||||||||||
| 151 | 20 | return $r; | |||||||||||||||||||||||||||
| 152 | 5 | }; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 5 | ▶ | sub generate_inc { | ||||||||||||||||||||||||||
|
Subroutine
generate_inc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 156 | 5 | my($self) = @_; | |||||||||||||||||||||||||||
| 157 | 5 | my $reader = $self->reader; | |||||||||||||||||||||||||||
| 158 | 5 | my $writer = $self->writer; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 20 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 161 | 20 | my($instance) = @_; | |||||||||||||||||||||||||||
| 162 | 20 | ▶ | if(@_ != 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 10 | $self->argument_error('inc', 1, 1, scalar @_); | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | 10 | my $v = $reader->( $instance ); | |||||||||||||||||||||||||||
| 166 | 10 | $v++; | |||||||||||||||||||||||||||
| 167 | 10 | $writer->( $instance, $v ); | |||||||||||||||||||||||||||
| 168 | 5 | }; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 5 | ▶ | sub generate_clear { | ||||||||||||||||||||||||||
|
Subroutine
generate_clear: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 172 | 5 | my($self) = @_; | |||||||||||||||||||||||||||
| 173 | 5 | my $writer = $self->writer; | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 20 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 176 | 20 | my($instance) = @_; | |||||||||||||||||||||||||||
| 177 | 20 | ▶ | if(@_ != 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 10 | $self->argument_error('clear', 1, 1, scalar @_); | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | 10 | $writer->( $instance, '' ); | |||||||||||||||||||||||||||
| 181 | 5 | }; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 5 | ▶ | sub generate_length { | ||||||||||||||||||||||||||
|
Subroutine
generate_length: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 185 | 5 | my($self) = @_; | |||||||||||||||||||||||||||
| 186 | 5 | my $reader = $self->reader; | |||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 30 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 189 | 30 | ▶ | if(@_ != 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 10 | $self->argument_error('length', 1, 1, scalar @_); | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | 20 | return length( $reader->($_[0]) ); | |||||||||||||||||||||||||||
| 193 | 5 | }; | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 20 | ▶ | sub generate_substr { | ||||||||||||||||||||||||||
|
Subroutine
generate_substr: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 197 | 20 | my($self) = @_; | |||||||||||||||||||||||||||
| 198 | 20 | my $reader = $self->reader; | |||||||||||||||||||||||||||
| 199 | 20 | my $writer = $self->writer; | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 150 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||
| 202 | 150 | my($instance, $offset, $length, $replacement) = @_; | |||||||||||||||||||||||||||
| 203 | 150 | ▶ | if(@_ < 2 or @_ > 4) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ < 2 or @_ > 4
MC/DC100%2/2
@_ < 2 or @_ > 4
@_ < 2
@_ > 4
Truth table100%3/3
A or B
A= @_ < 2B= @_ > 4
| |||||||||||||||||||||||||||||
| 204 | 20 | $self->argument_error('substr', 2, 4, scalar @_); | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 130 | my $v = $reader->($instance); | |||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 130 | ▶ | Mouse::Util::TypeConstraints::Int($offset) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | or $self->meta->throw_error( | ||||||||||||||||||||||||||||
| 211 | "The first argument passed to substr must be an integer"); | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 120 | ▶ | if(defined $length) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 100 | ▶ | Mouse::Util::TypeConstraints::Int($length) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | or $self->meta->throw_error( | ||||||||||||||||||||||||||||
| 216 | "The second argument passed to substr must be an integer"); | ||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | else { | ||||||||||||||||||||||||||||
| 219 | 20 | $length = length($v); | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 110 | my $ret; | |||||||||||||||||||||||||||
| 223 | 110 | ▶ | if ( defined $replacement ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 224 | 60 | ▶ | Mouse::Util::TypeConstraints::Str($replacement) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | or $self->meta->throw_error( | ||||||||||||||||||||||||||||
| 226 | "The third argument passed to substr must be a string"); | ||||||||||||||||||||||||||||
| 227 | 50 | $ret = substr( $v, $offset, $length, $replacement ); | |||||||||||||||||||||||||||
| 228 | 50 | $writer->( $instance, $v ); | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | else { | ||||||||||||||||||||||||||||
| 231 | 50 | $ret = substr( $v, $offset, $length ); | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 100 | return $ret; | |||||||||||||||||||||||||||
| 235 | 20 | }; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 2 | ▶ | no Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 239 | 2 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | __END__ | ||||||||||||||||||||||||||||