| 1 | package Class::Param::Encoding; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use base 'Class::Param::Decorator'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Encode qw[]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Params::Validate qw[]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | my $class = ref $_[0] ? ref shift : shift; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | my ( $decorated, $encoding ) = Params::Validate::validate_with( | ||||||||||||||||||||||||||||
| 14 | params => \@_, | ||||||||||||||||||||||||||||
| 15 | spec => [ | ||||||||||||||||||||||||||||
| 16 | { | ||||||||||||||||||||||||||||
| 17 | type => Params::Validate::OBJECT, | ||||||||||||||||||||||||||||
| 18 | isa => 'Class::Param::Base', | ||||||||||||||||||||||||||||
| 19 | optional => 0 | ||||||||||||||||||||||||||||
| 20 | }, | ||||||||||||||||||||||||||||
| 21 | { | ||||||||||||||||||||||||||||
| 22 | type => Params::Validate::SCALAR, | ||||||||||||||||||||||||||||
| 23 | default => 'UTF-8', | ||||||||||||||||||||||||||||
| 24 | optional => 1, | ||||||||||||||||||||||||||||
| 25 | callbacks => { | ||||||||||||||||||||||||||||
| 26 | 0 | ▶ | 'valid Encode encoding' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 27 | 0 | return Encode::find_encoding( $_[0] ); | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | 1 | ], | |||||||||||||||||||||||||||
| 32 | called => "$class\::new" | ||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | return bless( [ $decorated, Encode::find_encoding($encoding) ], $class ); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 8 | ▶ | sub encoding { return $_[0]->[1] } | ||||||||||||||||||||||||||
|
Subroutine
encoding: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 8 | ▶ | sub get { | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | 8 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 8 | my @values = (); | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 8 | foreach my $value ( $self->decorated->param($name) ) { | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 10 | ▶ | if ( ref $value || Encode::is_utf8($value) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $value or &Encode::is_utf8($value)
MC/DC50%1/2
ref $value or &Encode::is_utf8($value)
ref $value
&Encode::is_utf8($value)
Truth table66%2/3
A or B
A= ref $valueB= &Encode::is_utf8($value)
| |||||||||||||||||||||||||||||
| 48 | 2 | push @values, $value; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | else { | ||||||||||||||||||||||||||||
| 51 | 8 | push @values, $self->encoding->decode( $value, Encode::FB_CROAK ); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 8 | ▶ | return @values > 1 ? \@values : $values[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 2 | 1; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||||||||||