| 1 | package Mail::BIMI::Record::Location; | ||||||||||||||||||
| 2 | # ABSTRACT: Class to model a BIMI location | ||||||||||||||||||
| 3 | 29 | our $VERSION = '3.20261116'; # VERSION | |||||||||||||||||
| 4 | 29 | ▶ | use 5.20.0; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | 29 | ▶ | use Moose; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 6 | 29 | ▶ | use Mail::BIMI::Prelude; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | 29 | ▶ | use Mail::BIMI::Indicator; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | 29 | extends 'Mail::BIMI::Base'; | |||||||||||||||||
| 10 | 29 | with 'Mail::BIMI::Role::HasError'; | |||||||||||||||||
| 11 | 29 | has is_location_valid => ( is => 'rw', lazy => 1, builder => '_build_is_location_valid' ); | |||||||||||||||||
| 12 | 29 | has uri => ( is => 'rw', isa => 'Maybe[Str]', required => 1, | |||||||||||||||||
| 13 | documentation => 'inputs: URI of Indicator', ); | ||||||||||||||||||
| 14 | 29 | has is_valid => ( is => 'rw', lazy => 1, builder => '_build_is_valid', | |||||||||||||||||
| 15 | documentation => 'Is this Location record valid' ); | ||||||||||||||||||
| 16 | 29 | has indicator => ( is => 'rw', lazy => 1, builder => '_build_indicator', | |||||||||||||||||
| 17 | documentation => 'Mail::BIMI::Indicator object for this location' ); | ||||||||||||||||||
| 18 | 0 | ▶ | has is_relevant => ( is => 'rw', lazy => 1, default => sub{return 1}, | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 19 | 29 | documentation => 'Is the location relevant' ); | |||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | |||||||||||||||||||
| 22 | 26 | ▶ | sub _build_is_location_valid($self) { | ||||||||||||||||
|
Subroutine
_build_is_location_valid: called CC=5 SCAR=16.1
| |||||||||||||||||||
| 23 | # Check is_valid without checking indicator, because recursion! | ||||||||||||||||||
| 24 | 26 | ▶ | if ( !defined $self->uri ) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 25 | 1 | $self->add_error('MISSING_L_TAG'); | |||||||||||||||||
| 26 | } | ||||||||||||||||||
| 27 | elsif ( $self->uri eq '' ) { | ||||||||||||||||||
| 28 | 1 | $self->add_error('EMPTY_L_TAG'); | |||||||||||||||||
| 29 | } | ||||||||||||||||||
| 30 | elsif ( ! ( $self->uri =~ /^https:\/\// ) ) { | ||||||||||||||||||
| 31 | 1 | $self->add_error('INVALID_TRANSPORT_L'); | |||||||||||||||||
| 32 | } | ||||||||||||||||||
| 33 | else { | ||||||||||||||||||
| 34 | } | ||||||||||||||||||
| 35 | |||||||||||||||||||
| 36 | 26 | ▶ | return 0 if $self->errors->@*; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 37 | 23 | return 1; | |||||||||||||||||
| 38 | } | ||||||||||||||||||
| 39 | |||||||||||||||||||
| 40 | 26 | ▶ | sub _build_is_valid($self) { | ||||||||||||||||
|
Subroutine
_build_is_valid: called CC=4 SCAR=14.5
| |||||||||||||||||||
| 41 | 26 | ▶ | return 0 if !$self->is_location_valid; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 42 | 23 | ▶ | if ( !$self->indicator->is_valid ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 43 | 0 | $self->add_error_object( $self->indicator->errors ); | |||||||||||||||||
| 44 | } | ||||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | 23 | ▶ | return 0 if $self->errors->@*; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 47 | 23 | $self->log_verbose('Location is valid'); | |||||||||||||||||
| 48 | 23 | return 1; | |||||||||||||||||
| 49 | } | ||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | 23 | ▶ | sub _build_indicator($self) { | ||||||||||||||||
|
Subroutine
_build_indicator: called CC=3 SCAR=11.7
| |||||||||||||||||||
| 52 | 23 | ▶ | return if !$self->is_location_valid; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 53 | 23 | ▶ | return if !$self->is_relevant; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 54 | 23 | return Mail::BIMI::Indicator->new( uri => $self->uri, bimi_object => $self->bimi_object, source => 'Location' ); | |||||||||||||||||
| 55 | } | ||||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | |||||||||||||||||||
| 58 | 5 | ▶ | sub finish($self) { | ||||||||||||||||
|
Subroutine
finish: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||
| 59 | 5 | ▶ | $self->indicator->finish if $self->indicator; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 60 | } | ||||||||||||||||||
| 61 | |||||||||||||||||||
| 62 | 29 | 1; | |||||||||||||||||
| 63 | |||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||