| 1 | 5 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | package LINQ::FieldSet; | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use Class::Tiny qw( fields seen_asterisk ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use LINQ::Util::Internal (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 59 | ▶ | sub _known_parameter_names { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_known_parameter_names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 59 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 15 | 59 | return (); | |||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 60 | ▶ | sub BUILDARGS { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 60 | my ( $class, @args ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 60 | ▶ | if ( @args == 1 and ref( $args[0] ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@args == 1 and ref $args[0] eq "HASH"
MC/DC100%2/2
@args == 1 and ref $args[0] eq "HASH"
@args == 1
ref $args[0] eq "HASH"
Truth table100%3/3
A and B
A= @args == 1B= ref $args[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | return $args[0]; | |||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 59 | require LINQ::Field; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 59 | my %known = $class->_known_parameter_names; | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 59 | my @fields; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 59 | my $idx = 0; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 59 | my $seen_asterisk; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 59 | ▶ | ARG: while ( @args ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 78 | my $value = shift @args; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 78 | ▶ | if ( $value eq '*' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 5 | $seen_asterisk = 1; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | next ARG; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 73 | my %params = (); | |||||||||||||||||||||||||||||||||||||||||
| 40 | 73 | ▶ | while ( @args and !ref $args[0] and $args[0] =~ /\A-/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@args and not ref $args[0] and $args[0] =~ /\A-/
@args and not ref $args[0]
MC/DC100%3/3
@args and not ref $args[0] and $args[0] =~ /\A-/
@args
not ref $args[0]
$args[0] =~ /\A-/
Truth table100%4/4
A and not(B) and C
A= @argsB= not ref $args[0]C= $args[0] =~ /\A-/
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 77 | my $p_name = substr( shift( @args ), 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 42 | 77 | ▶ | if ( $known{$p_name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 60 | $params{$p_name} = shift( @args ); | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | elsif ( exists $known{$p_name} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 16 | $params{$p_name} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | LINQ::Util::Internal::throw( | |||||||||||||||||||||||||||||||||||||||||
| 50 | 'CallerError', | ||||||||||||||||||||||||||||||||||||||||||
| 51 | message => "Unknown field parameter '$p_name'", | ||||||||||||||||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | } #/ while ( @args and !ref $args...) | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 72 | my $field = 'LINQ::Field'->new( | |||||||||||||||||||||||||||||||||||||||||
| 57 | value => $value, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | index => ++$idx, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | params => \%params, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 72 | push @fields, $field; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } #/ ARG: while ( @args ) | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 58 | fields => \@fields, | |||||||||||||||||||||||||||||||||||||||||
| 66 | seen_asterisk => $seen_asterisk, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 68 | } #/ sub BUILDARGS | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 11 | ▶ | sub fields_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fields_hash: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 11 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 72 | 11 | ▶ | $self->{fields_hash} ||= $self->_build_fields_hash; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$self->{"fields_hash"} ||= $self->_build_fields_hash
MC/DC100%2/2
$self->{"fields_hash"} ||= $self->_build_fields_hash
$self->{"fields_hash"}
$self->_build_fields_hash
Truth table100%3/3
A ||= B
A= $self->{"fields_hash"}B= $self->_build_fields_hash
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 7 | ▶ | sub _build_fields_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_fields_hash: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 7 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 7 | my %fields; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 7 | foreach my $field ( @{ $self->fields } ) { | |||||||||||||||||||||||||||||||||||||||||
| 79 | 17 | $fields{ $field->name } = $field; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 7 | return \%fields; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | __END__ | ||||||||||||||||||||||||||||||||||||||||||