| 1 | package JSON::Types::Flexible; | ||||||||||||||||||||
| 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 | ▶ | use utf8; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 5 | our $VERSION = "0.02"; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 5 | ▶ | use JSON::Types (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 5 | ▶ | use List::MoreUtils qw/uniq/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 5 | ▶ | use Sub::Install; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | use constant { | ||||||||||||||||||||
| 13 | 5 | SUB_ALIAS => { | |||||||||||||||||||
| 14 | number => 'number', | ||||||||||||||||||||
| 15 | string => 'string', | ||||||||||||||||||||
| 16 | bool => 'bool', | ||||||||||||||||||||
| 17 | boolean => 'bool', | ||||||||||||||||||||
| 18 | }, | ||||||||||||||||||||
| 19 | STRICT_SUBS => [qw/ | ||||||||||||||||||||
| 20 | number | ||||||||||||||||||||
| 21 | string | ||||||||||||||||||||
| 22 | boolean | ||||||||||||||||||||
| 23 | /], | ||||||||||||||||||||
| 24 | LOOSE_SUBS => [qw/ | ||||||||||||||||||||
| 25 | bool | ||||||||||||||||||||
| 26 | /], | ||||||||||||||||||||
| 27 | 5 | ▶ | }; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | BEGIN { | ||||||||||||||||||||
| 30 | 5 | ▶ | for (keys %{SUB_ALIAS()}) { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 31 | Sub::Install::install_sub({ | ||||||||||||||||||||
| 32 | 20 | code => SUB_ALIAS->{$_}, | |||||||||||||||||||
| 33 | from => 'JSON::Types', | ||||||||||||||||||||
| 34 | into => __PACKAGE__, | ||||||||||||||||||||
| 35 | as => $_, | ||||||||||||||||||||
| 36 | }); | ||||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | sub import { | ||||||||||||||||||||
| 41 | 4 | ▶ | my ($pkg, @args) = @_; | ||||||||||||||||||
|
Subroutine
import: called CC=5 SCAR=16.1
| |||||||||||||||||||||
| 42 | 4 | my $class = caller; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 4 | my @subs; | |||||||||||||||||||
| 45 | 4 | ▶ | if (@args == 0) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 46 | 2 | push @subs, @{STRICT_SUBS()}; | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | ▶ | elsif ($args[0] eq ':loose' || $args[0] eq ':all') { | |||||||||||||||||||
|
Condition66%2/3
$args[0] eq ":loose" or $args[0] eq ":all"
MC/DC50%1/2
$args[0] eq ":loose" or $args[0] eq ":all"
$args[0] eq ":loose"
$args[0] eq ":all"
Truth table66%2/3
A or B
A= $args[0] eq ":loose"B= $args[0] eq ":all"
| |||||||||||||||||||||
| 49 | 1 | push @subs, @{STRICT_SUBS()}, @{LOOSE_SUBS()}; | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | else { | ||||||||||||||||||||
| 52 | 1 | push @subs, @args; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 4 | for (uniq @subs) { | |||||||||||||||||||
| 56 | Sub::Install::install_sub({ | ||||||||||||||||||||
| 57 | 12 | code => SUB_ALIAS->{$_}, | |||||||||||||||||||
| 58 | from => 'JSON::Types', | ||||||||||||||||||||
| 59 | into => $class, | ||||||||||||||||||||
| 60 | as => $_, | ||||||||||||||||||||
| 61 | }); | ||||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 5 | 1; | |||||||||||||||||||
| 66 | __END__ | ||||||||||||||||||||