Query/Field/SWISH.pm

filter: Statementstmt 100% 16 / 16 Branchbran 100% 2 / 2 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 100% 25 / 25 CC 3 SCAR 7.9
CC
3
Cov
100%
BUILD
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« Query.pm ↑ Summary Query/Field.pm »
1 package Search::Query::Field::SWISH;
2 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 extends 'Search::Query::Field';
4  
5 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 has 'type' => ( is => 'rw' );
8 4 has 'is_int' => ( is => 'rw' );
9  
10 4 our $VERSION = '0.306';
11  
12 =head1 NAME
13  
14 Search::Query::Field::SWISH - query field representing a Swish MetaName
15  
16 =head1 SYNOPSIS
17  
18 my $field = Search::Query::Field::SWISH->new(
19 name => 'foo',
20 alias_for => [qw( bar bing )],
21 );
22  
23 =head1 DESCRIPTION
24  
25 Search::Query::Field::SWISH implements field
26 validation and aliasing in SWISH search queries.
27  
28 =head1 METHODS
29  
30 This class is a subclass of Search::Query::Field. Only new or overridden
31 methods are documented here.
32  
33 =head2 BUILD
34  
35 Available params are also standard attribute accessor methods.
36  
37 =over
38  
39 =item type
40  
41 The column type.a
42  
43 =item is_int
44  
45 Set if C<type> matches m/int|num|date/.
46  
47 =back
48  
49 =cut
50  
51 sub BUILD {
52 25 ▶ my $self = shift;
Subroutine BUILD: called CC=3 SCAR=11.0
Pod documented
53  
54 25 ▶ $self->{type} ||= 'char';
Condition100%2/2
$self->{"type"} ||= "char"
l!l
223
MC/DC100%1/1
$self->{"type"} ||= "char"
$self->{"type"}
Truth table100%2/2
A
A= $self->{"type"}
Aresult
11
00
55  
56 # numeric types
57 25 ▶ if ( $self->{type} =~ m/int|date|num/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'type'} =~ /int|date|num/) { } 1 24 25
58 1 $self->{is_int} = 1;
59 }
60  
61 # text types
62 else {
63 24 $self->{is_int} = 0;
64 }
65  
66 }
67  
68 4 1;
69  
70 __END__
« Query.pm ↑ Summary Query/Field.pm »