Fey/Literal.pm

filter: Statementstmt 100% 54 / 54 Branchbran 100% 6 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 16 / 16 Podpod 100% 1 / 1 totaltotal 97.5% 80 / 82 CC 5 SCAR 6.9
CC
5
Cov
98%
new_from_scalar
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Fey/Role/SQL/HasOrderByClause.pm ↑ Summary Fey/Role/SetOperation.pm »
1 package Fey::Literal;
2  
3 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 28 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 28 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 28 our $VERSION = '0.44';
8  
9 28 ▶use Fey::FakeDBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 28 ▶use Fey::Literal::Function;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 28 ▶use Fey::Literal::Null;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 28 ▶use Fey::Literal::Number;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 28 ▶use Fey::Literal::String;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 28 ▶use Fey::Literal::Term;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 28 ▶use Fey::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 28 ▶use Scalar::Util qw( blessed looks_like_number );
Subroutine BEGIN: called CC=1 SCAR=0.0
17 28 ▶use overload ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 # This needs to come before we load subclasses or shit blows up
20 # because we end up with a metaclass object that is a
21 # Class::MOP::Class, not Moose::Meta::Class.
22 28 ▶use Moose 2.1200;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 28 ▶use MooseX::SemiAffordanceAccessor 0.03;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 28 ▶use MooseX::StrictConstructor 0.13;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 235 ▶sub new_from_scalar {
Subroutine new_from_scalar: called CC=5 SCAR=16.1
Pod documented
27 235 shift;
28 235 my $val = shift;
29  
30 235 ▶ return Fey::Literal::Null->new()
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 11 224 235
31 unless defined $val;
32  
33 # Freaking Perl overloading is so broken! An overloaded reference
34 # will not pass the type constraints, so we need to manually
35 # convert it to a non-ref.
36 224 ▶ if ( blessed $val && overload::Overloaded($val) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($val) and overload::Overloaded($val)) 2 222 224
Condition66%2/3
builtin::blessed($val) and overload::Overloaded($val)
!ll&&!rl&&r
22202
MC/DC50%1/2
builtin::blessed($val) and overload::Overloaded($val)
builtin::blessed($val) overload::Overloaded($val)
Truth table66%2/3
A and B
A= builtin::blessed($val)B= overload::Overloaded($val)
ABresult
0X0
100
111
37  
38 # The stringification method will be derived from the
39 # numification method if needed. This might produce strange
40 # results in the case of something that overloads both
41 # operations, like a number class that returns either 2 or
42 # "two", but in that case the author of the class made our
43 # life impossible anyway ;)
44 2 $val = $val . '';
45 }
46  
47 224 ▶ return looks_like_number($val)
Branch: 1 branch
BranchTrueFalseTotal
&looks_like_number($val) ? : 147 77 224
48 ? Fey::Literal::Number->new($val)
49 : Fey::Literal::String->new($val);
50 }
51  
52 28 __PACKAGE__->meta()->make_immutable();
53  
54 28 1;
55  
56 # ABSTRACT: Factory for making a literal piece of a SQL statement
57  
58 __END__
« Fey/Role/SQL/HasOrderByClause.pm ↑ Summary Fey/Role/SetOperation.pm »