EntityModel/Query/Table.pm

filter: Statementstmt 70.8% 17 / 24 Branchbran 30.0% 3 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 3 / 3 Podpod 100% 2 / 2 totaltotal 59.0% 26 / 44 CC 7 SCAR 19.5
CC
7
Cov
57%
asString
10.4
new
3.4
BEGIN
1.0
CRAP 7.0
« EntityModel/Model.pm ↑ Summary EntityModel/Query/SubQuery.pm »
1 package EntityModel::Query::Table;
2 {
3 37 $EntityModel::Query::Table::VERSION = '0.102';
4 }
5 37 ▶use EntityModel::Class {
Subroutine BEGIN: called CC=1 SCAR=0.0
6 37 '_isa' => [qw(EntityModel::Query::Base)],
7 'entity' => { type => 'EntityModel::Entity', defer => 1 },
8 'table' => 'string',
9 'alias' => 'string',
10 37 };
11  
12 =head1 NAME
13  
14 EntityModel::Query::Table
15  
16 =head1 VERSION
17  
18 version 0.102
19  
20 =head1 SYNOPSIS
21  
22 See L<Entitymodel::Query>.
23  
24 =head1 DESCRIPTION
25  
26 See L<Entitymodel::Query>.
27  
28 =cut
29  
30 =head1 METHODS
31  
32 =cut
33  
34 =head2 new
35  
36 =cut
37  
38 10 ▶sub new {
Subroutine new: called CC=3 SCAR=12.3
Pod documented
39 10 my $class = shift;
40 10 my $self = bless { }, $class;
41  
42 # Handle plain value
43 10 ▶ if(@_ == 1 && !ref $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and not ref $_[0]) { } 10 0 10
Condition33%1/3
@_ == 1 and not ref $_[0]
!ll&&!rl&&r
0010
MC/DC0%0/2
@_ == 1 and not ref $_[0]
@_ == 1 not ref $_[0]
Truth table33%1/3
A and not(B)
A= @_ == 1B= not ref $_[0]
ABresult
0X0
100
111
44 10 $self->table($_[0]);
45 } else {
46 0 $self->entity($_[0]);
47 }
48  
49 10 return $self;
50 }
51  
52 =head2 asString
53  
54 =cut
55  
56 20 ▶sub asString {
Subroutine asString: called CC=5 SCAR=23.4
Pod documented
57 20 my $self = shift;
58 20 my $str = '';
59 20 ▶ if($self->table) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->table) { } 20 0 20
60 20 $str = $self->table;
61 } else {
62 0 ▶ return $self->entity unless ref($self->entity);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->entity 0 0 0
63 0 ▶ if(ref $self->entity eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->entity eq "HASH") 0 0 0
64 0 my ($alias, $t) = %{$self->entity};
65 0 return "$t as $alias";
66 }
67 0 return '"' . $self->entity->schema . '"."' . $self->entity->name . '"';
68 }
69 20 ▶ $str .= ' as ' . $self->alias if $self->alias;
Branch: 1 branch
BranchTrueFalseTotal
if $self->alias 0 20 20
70 20 return $str;
71 }
72  
73 37 1;
74  
75 __END__
« EntityModel/Model.pm ↑ Summary EntityModel/Query/SubQuery.pm »