| 1 | package WebService::TypeSafe::Question; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | sub _args { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_args: called CC=4 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 11 | my (@args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | return %{ $args[0] } if @args == 1 && ref($args[0]) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@args == 1 and ref $args[0] eq "HASH"
MC/DC0%0/2
@args == 1 and ref $args[0] eq "HASH"
@args == 1
ref $args[0] eq "HASH"
Truth table33%1/3
A and B
A= @args == 1B= ref $args[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 11 | ▶ | croak 'constructor expects named arguments' if @args % 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 11 | return @args; | |||||||||||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 11 | ▶ | sub _base { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_base: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 11 | my ($class, $type, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 11 | my %args = _args(@args); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 11 | my %allowed = map { $_ => 1 } qw(instructions criteria); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 11 | my @unknown = grep { !$allowed{$_} } keys %args; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 11 | ▶ | croak 'unknown question field(s): ' . join(', ', sort @unknown) if @unknown; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 11 | return bless { type => $type, %args }, $class; | |||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 6 | ▶ | sub as_hash { return { %{ $_[0] } } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_hash: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | sub type { return $_[0]->{type} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub instructions { return $_[0]->{instructions} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instructions: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub criteria { return $_[0]->{criteria} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
criteria: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | package WebService::TypeSafe::Question::Choice; | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | use parent -norequire, 'WebService::TypeSafe::Question'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | my ($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | my $self = $class->_base('choice', @args); | |||||||||||||||||||||||||||||||||||||||||
| 35 | croak 'Choice criteria must be a nonempty hash reference' | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 3 | ▶ | unless ref($self->{criteria}) eq 'HASH' && keys %{ $self->{criteria} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $self->{"criteria"} eq "HASH" and keys %{$$self{"criteria"};}
MC/DC50%1/2
ref $self->{"criteria"} eq "HASH" and keys %{$$self{"criteria"};}
ref $self->{"criteria"} eq "HASH"
keys %{$$self{"criteria"};}
Truth table66%2/3
A and B
A= ref $self->{"criteria"} eq "HASH"B= keys %{$$self{"criteria"};}
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | croak 'Choice accepts at most 255 criteria' if keys(%{ $self->{criteria} }) > 255; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | package WebService::TypeSafe::Question::Noul; | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | ▶ | use parent -norequire, 'WebService::TypeSafe::Question'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 6 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=29.5
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | my ($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 6 | my $self = $class->_base('noul', @args); | |||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | ▶ | if (exists $self->{criteria} && defined $self->{criteria}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"criteria"} and defined $self->{"criteria"}
MC/DC0%0/2
exists $self->{"criteria"} and defined $self->{"criteria"}
exists $self->{"criteria"}
defined $self->{"criteria"}
Truth table33%1/3
A and B
A= exists $self->{"criteria"}B= defined $self->{"criteria"}
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | croak 'Noul criteria must be a hash reference' | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | unless ref($self->{criteria}) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my @bad = grep { $_ ne 'true' && $_ ne 'false' } keys %{ $self->{criteria} }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_ ne 'true' && $_ ne 'false'
MC/DC0%0/2
$_ ne 'true' && $_ ne 'false'
$_ ne 'true'
$_ ne 'false'
Truth table0%0/3
A && B
A= $_ ne 'true'B= $_ ne 'false'
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | croak 'Noul criteria only accepts true and false keys' if @bad; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | package WebService::TypeSafe::Question::Score; | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | ▶ | use parent -norequire, 'WebService::TypeSafe::Question'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | my ($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | my $self = $class->_base('score', @args); | |||||||||||||||||||||||||||||||||||||||||
| 62 | croak 'Score criteria must be an array reference with 2 to 10 levels' | ||||||||||||||||||||||||||||||||||||||||||
| 63 | unless ref($self->{criteria}) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | ▶ | && @{ $self->{criteria} } >= 2 && @{ $self->{criteria} } <= 10; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
ref $self->{"criteria"} eq "ARRAY" and @{$self->{"criteria"};} >= 2 and @{$self->{"criteria"};} <= 10
ref $self->{"criteria"} eq "ARRAY" and @{$self->{"criteria"};} >= 2
MC/DC33%1/3
ref $self->{"criteria"} eq "ARRAY" and @{$self->{"criteria"};} >= 2 and @{$self->{"criteria"};} <= 10
ref $self->{"criteria"} eq "ARRAY"
@{$self->{"criteria"};} >= 2
@{$self->{"criteria"};} <= 10
Truth table50%2/4
A and B and C
A= ref $self->{"criteria"} eq "ARRAY"B= @{$self->{"criteria"};} >= 2C= @{$self->{"criteria"};} <= 10
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||