| 1 | #!/usr/bin/perl | ||||||||||||||||||||
| 2 | package SQL::QueryBuilder::Pretty::Print; | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 2 | our $VERSION = '0.01'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 2 | ▶ | use Carp qw(croak); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 13 | 0 | my $class = shift; | |||||||||||||||||||
| 14 | 0 | my %self = ( | |||||||||||||||||||
| 15 | '-indent_ammount' => 4, | ||||||||||||||||||||
| 16 | '-indent_char' => ' ', | ||||||||||||||||||||
| 17 | '-new_line' => "\n", | ||||||||||||||||||||
| 18 | @_, | ||||||||||||||||||||
| 19 | 'indent_level' => 0, | ||||||||||||||||||||
| 20 | 'indent_multiplier' => 1, | ||||||||||||||||||||
| 21 | 'skip_next_space' => 0, | ||||||||||||||||||||
| 22 | 'query' => undef, | ||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 0 | ▶ | return bless { %self }, ref $class || $class; | ||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | ▶ | sub _generic_method { | ||||||||||||||||||
|
Subroutine
_generic_method: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 29 | 0 | my $self = shift; | |||||||||||||||||||
| 30 | 0 | my $key = shift; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | ▶ | $self->{ $key } = shift if defined $_[0]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | return $self->{ $key }; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | ▶ | sub current_indent { | ||||||||||||||||||
|
Subroutine
current_indent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 38 | 0 | my $self = shift; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | return | ||||||||||||||||||||
| 41 | 0 | $self->indent_char x ( $self->indent_level * $self->indent_ammount ); | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | ▶ | sub indent { | ||||||||||||||||||
|
Subroutine
indent: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 45 | 0 | my $self = shift; | |||||||||||||||||||
| 46 | 0 | ▶ | my $multiplier = shift || 1; | ||||||||||||||||||
|
Condition0%0/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 0 | $self->indent_level(+1 * $multiplier); | |||||||||||||||||||
| 49 | 0 | $self->var( $self->current_indent ); | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | return 1; | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 0 | ▶ | sub indent_ammount { return shift->{'-indent_ammount'}; } | ||||||||||||||||||
|
Subroutine
indent_ammount: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 55 | 0 | ▶ | sub indent_char { return shift->{'-indent_char'}; } | ||||||||||||||||||
|
Subroutine
indent_char: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 0 | ▶ | sub indent_level { | ||||||||||||||||||
|
Subroutine
indent_level: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 58 | 0 | my $self = shift; | |||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 0 | ▶ | $self->{'indent_level'} += shift if defined $_[0]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | return $self->{'indent_level'} >= 0 ? $self->{'indent_level'} : 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | ▶ | sub indent_multiplier { return shift->_generic_method( 'indent_multiplier', @_ ); } | ||||||||||||||||||
|
Subroutine
indent_multiplier: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | ▶ | sub new_line { | ||||||||||||||||||
|
Subroutine
new_line: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 68 | 0 | my $self = shift; | |||||||||||||||||||
| 69 | 0 | $self->var( $self->{'-new_line'} ); | |||||||||||||||||||
| 70 | 0 | return 1; | |||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 0 | ▶ | sub query { return shift->{'query'}; } | ||||||||||||||||||
|
Subroutine
query: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 0 | ▶ | sub unindent { | ||||||||||||||||||
|
Subroutine
unindent: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 76 | 0 | my $self = shift; | |||||||||||||||||||
| 77 | 0 | ▶ | my $multiplier = shift || 1; | ||||||||||||||||||
|
Condition0%0/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 0 | $self->indent_level(-1 * $multiplier); | |||||||||||||||||||
| 80 | 0 | $self->var( $self->current_indent ); | |||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 0 | return 1; | |||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 0 | ▶ | sub var { | ||||||||||||||||||
|
Subroutine
var: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 86 | 0 | my $self = shift; | |||||||||||||||||||
| 87 | 0 | $self->{'query'} .= shift; | |||||||||||||||||||
| 88 | 0 | return 1; | |||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 0 | ▶ | sub skip_next_space { | ||||||||||||||||||
|
Subroutine
skip_next_space: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 92 | 0 | return shift->_generic_method( 'skip_next_space' , @_ ); | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | 2 | 1; | |||||||||||||||||||
| 96 | __END__ | ||||||||||||||||||||