lib/Types/Standard/Tied.pm

filter: Statementstmt 100% 49 / 49 Branchbran 77.7% 14 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 13 / 13 Podpod n/a totaltotal 95.0% 76 / 80 CC 10 SCAR 9.7
CC
10
Cov
94%
__inline_generator
4.0
__ANON__
4.0
__constraint_generator
4.0
CRAP 2.6
« blib/lib/Eval/TypeTiny/CodeAccumulator.pm ↑ Summary blib/lib/Devel/TypeTiny/Perl58Compat.pm »
1 # INTERNAL MODULE: guts for Tied type from Types::Standard.
2  
3 package Types::Standard::Tied;
4  
5 3 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 $Types::Standard::Tied::AUTHORITY = 'cpan:TOBYINK';
11 3 $Types::Standard::Tied::VERSION = '2.010001';
12 }
13  
14 3 $Types::Standard::Tied::VERSION =~ tr/_//d;
15  
16 3 ▶use Type::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 ▶use Types::Standard ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18 3 ▶use Types::TypeTiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak }
Subroutine _croak: called CC=1 SCAR=0.0
21  
22 3 ▶no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 37 ▶sub __constraint_generator {
Subroutine __constraint_generator: called CC=4 SCAR=13.9
25 37 ▶ return Types::Standard->meta->get_type( 'Tied' ) unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 37 37
26
27 37 Type::Tiny::check_parameter_count_for_parameterized_type( 'Types::Standard', 'Tied', \@_, 1 );
28 37 my $param = Types::TypeTiny::to_TypeTiny( shift );
29 37 ▶ unless ( Types::TypeTiny::is_TypeTiny( $param ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (Types::TypeTiny::is_TypeTiny($param)) 27 10 37
30 27 ▶ Types::TypeTiny::is_StringLike( $param )
Branch: 1 branch
BranchTrueFalseTotal
Types::TypeTiny::is_StringLike($param) or &_croak("Parameter to Tied[`a] expected to be a class name; got $param") 26 1 27
31 or _croak( "Parameter to Tied[`a] expected to be a class name; got $param" );
32 26 require Type::Tiny::Class;
33 26 $param = "Type::Tiny::Class"->new( class => "$param" );
34 }
35
36 36 my $check = $param->compiled_check;
37 33 ▶ sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
38 $check->(
39 tied(
40 11 ▶ Scalar::Util::reftype( $_ ) eq 'HASH' ? %{$_}
Branch: 1 branch
BranchTrueFalseTotal
builtin::reftype($_) eq 'ARRAY' ? : 11 11 22
41 11 ▶ : Scalar::Util::reftype( $_ ) eq 'ARRAY' ? @{$_}
Branch: 1 branch
BranchTrueFalseTotal
builtin::reftype($_) =~ /^(SCALAR|REF)$/ ? : 11 0 11
42 33 ▶ : Scalar::Util::reftype( $_ ) =~ /^(SCALAR|REF)$/ ? ${$_}
Branch: 1 branch
BranchTrueFalseTotal
builtin::reftype($_) eq 'HASH' ? : 11 22 33
43 : undef
44 )
45 );
46 36 };
47 } #/ sub __constraint_generator
48  
49 36 ▶sub __inline_generator {
Subroutine __inline_generator: called CC=4 SCAR=13.9
50 36 my $param = Types::TypeTiny::to_TypeTiny( shift );
51 36 ▶ unless ( Types::TypeTiny::is_TypeTiny( $param ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (Types::TypeTiny::is_TypeTiny($param)) 26 10 36
52 26 ▶ Types::TypeTiny::is_StringLike( $param )
Branch: 1 branch
BranchTrueFalseTotal
Types::TypeTiny::is_StringLike($param) or &_croak("Parameter to Tied[`a] expected to be a class name; got $param") 26 0 26
53 or _croak( "Parameter to Tied[`a] expected to be a class name; got $param" );
54 26 require Type::Tiny::Class;
55 26 $param = "Type::Tiny::Class"->new( class => "$param" );
56 }
57 36 ▶ return unless $param->can_be_inlined;
Branch: 1 branch
BranchTrueFalseTotal
unless $param->can_be_inlined 0 36 36
58
59 106 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
60 106 require B;
61 106 my $var = $_[1];
62 106 sprintf(
63 "%s and do { my \$TIED = tied(Scalar::Util::reftype($var) eq 'HASH' ? \%{$var} : Scalar::Util::reftype($var) eq 'ARRAY' ? \@{$var} : Scalar::Util::reftype($var) =~ /^(SCALAR|REF)\$/ ? \${$var} : undef); %s }",
64 Types::Standard::Ref()->inline_check( $var ),
65 $param->inline_check( '$TIED' )
66 );
67 }
68 36 } #/ sub __inline_generator
69  
70 3 1;
« blib/lib/Eval/TypeTiny/CodeAccumulator.pm ↑ Summary blib/lib/Devel/TypeTiny/Perl58Compat.pm »