File Coverage

blib/lib/Business/CPI/Role/Account/Address.pm
Criterion Covered Total %
statement 9 20 45.0
branch 0 8 0.0
condition 0 9 0.0
subroutine 3 5 60.0
pod n/a
total 12 42 28.5


line stmt bran cond sub pod time code
1             package Business::CPI::Role::Account::Address;
2             # ABSTRACT: Business::CPI role for Addresses
3 2     2   8196 use Moo::Role;
  2         5  
  2         14  
4 2     2   676 use utf8;
  2         14  
  2         14  
5 2     2   428 use Business::CPI::Util::Types qw/Country/;
  2         4  
  2         35  
6              
7             our $VERSION = '0.923'; # VERSION
8              
9             # TODO:
10             # move this to Business::CPI core
11              
12             has line1 => ( is => 'lazy' );
13             has line2 => ( is => 'lazy' );
14              
15             has street => ( is => 'rw' );
16             has number => ( is => 'rw' );
17             has district => ( is => 'rw' );
18             has complement => ( is => 'rw' );
19             has zip_code => ( is => 'rw' );
20             has city => ( is => 'rw' );
21             has state => ( is => 'rw' ); # TODO: compare against Brazilian UF's, if country eq br
22             has country => (
23             is => 'rw',
24             isa => Country,
25             coerce => Country->coercion,
26             );
27              
28             sub _build_line1 {
29 0     0     my $self = shift;
30              
31 0   0       my $street = $self->street || '';
32 0   0       my $number = $self->number || '';
33 0   0       my $compl = $self->complement || '';
34              
35 0 0         return unless $street;
36              
37 0 0 0       return $street unless ($number || $compl);
38              
39 0 0         return "$street, $number" unless $compl;
40 0 0         return "$street - $compl" unless $number;
41              
42 0           return "$street, $number - $compl";
43             }
44              
45             sub _build_line2 {
46 0     0     my $self = shift;
47              
48 0           return $self->district;
49             }
50              
51             1;
52              
53             __END__