« lib/Mail/AuthenticationResults/Parser.pm
↑ Summary
blib/lib/Mail/AuthenticationResults/Token/QuotedString.pm »
| 1 | package Mail::AuthenticationResults::Header::Version; | ||
| 2 | # ABSTRACT: Class modelling the AuthServID part of the Authentication Results Header | ||
| 3 | |||
| 4 | require 5.008; | ||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | our $VERSION = '2.20260216'; # VERSION | ||
| 8 | use Scalar::Util qw{ weaken }; | ||
| 9 | use Carp; | ||
| 10 | |||
| 11 | use base 'Mail::AuthenticationResults::Header::Base'; | ||
| 12 | |||
| 13 | |||
| 14 | sub _HAS_VALUE{ return 1; } | ||
| 15 | |||
| 16 | sub build_string { | ||
| 17 | my ( $self, $header ) = @_; | ||
| 18 | |||
| 19 | if ( ! $self->value() ) { | ||
| 20 | return; | ||
| 21 | } | ||
| 22 | |||
| 23 | if ( ref $self->parent() ne 'Mail::AuthenticationResults::Header::AuthServID' ) { | ||
| 24 | $header->separator( '/' ); | ||
| 25 | $header->space( ' ' ); | ||
| 26 | } | ||
| 27 | |||
| 28 | $header->string( $self->value() ); | ||
| 29 | |||
| 30 | return; | ||
| 31 | } | ||
| 32 | |||
| 33 | sub safe_set_value { | ||
| 34 | my ( $self, $value ) = @_; | ||
| 35 | |||
| 36 | $value = 1 if ! defined $value; | ||
| 37 | $value =~ s/[^0-9]//g; | ||
| 38 | $value = 1 if $value eq q{}; | ||
| 39 | |||
| 40 | $self->set_value( $value ); | ||
| 41 | return $self; | ||
| 42 | } | ||
| 43 | |||
| 44 | sub set_value { | ||
| 45 | my ( $self, $value ) = @_; | ||
| 46 | |||
| 47 | croak 'Does not have value' if ! $self->_HAS_VALUE(); # uncoverable branch true | ||
| 48 | # HAS_VALUE is 1 for this class | ||
| 49 | croak 'Value cannot be undefined' if ! defined $value; | ||
| 50 | croak 'Value must be numeric' if $value =~ /[^0-9]/; | ||
| 51 | |||
| 52 | $self->{ 'value' } = $value; | ||
| 53 | return $self; | ||
| 54 | } | ||
| 55 | |||
| 56 | 1; | ||
| 57 | |||
| 58 | __END__ |