Courriel/Header/ContentType.pm

filter: Statementstmt 100% 42 / 42 Branchbran 87.5% 7 / 8 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 95.3% 62 / 65 CC 6 SCAR 7.0
CC
6
Cov
96%
is_binary
3.0
__ANON__
3.0
_build_charset
2.0
CRAP 2.0
« Courriel/Role/HeaderWithAttributes.pm ↑ Summary Courriel/Role/Part.pm »
1 package Courriel::Header::ContentType;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 9 our $VERSION = '0.49';
8  
9 9 ▶use Courriel::Types qw( Maybe NonEmptyStr );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 9 extends 'Courriel::Header';
15  
16 9 with 'Courriel::Role::HeaderWithAttributes' => {
17 main_value_key => 'mime_type',
18 main_value_method => '_original_mime_type',
19 };
20  
21 9 has '+value' => (
22 required => 0,
23 lazy => 1,
24 builder => 'as_header_value',
25 );
26  
27 9 has '+name' => (
28 default => 'Content-Type',
29 );
30  
31 9 has mime_type => (
32 is => 'ro',
33 isa => NonEmptyStr,
34 required => 1,
35 );
36  
37 9 has _original_mime_type => (
38 is => 'ro',
39 isa => NonEmptyStr,
40 required => 1,
41 );
42  
43 9 has charset => (
44 is => 'ro',
45 isa => Maybe [NonEmptyStr],
46 init_arg => undef,
47 lazy => 1,
48 builder => '_build_charset',
49 );
50  
51 161 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
52 161 my $orig = shift;
53 161 my $class = shift;
54  
55 161 my $p = $class->$orig(@_);
56  
57 161 ▶ $p->{name} = 'Content-Type' unless exists $p->{name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $p->{"name"} 13 148 161
58  
59 161 ▶ return unless defined $p->{mime_type};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p->{"mime_type"} 0 161 161
60  
61 161 $p->{_original_mime_type} = $p->{mime_type};
62 161 $p->{mime_type} = lc $p->{mime_type};
63  
64 161 return $p;
65 9 };
66  
67 13 ▶sub _build_charset {
Subroutine _build_charset: called CC=2 SCAR=6.9
68 13 my $self = shift;
69  
70 13 ▶ return unless exists $self->_attributes()->{charset};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->_attributes->{"charset"} 7 6 13
71  
72 6 return $self->_attributes()->{charset}->value();
73 }
74  
75 13 ▶sub is_binary {
Subroutine is_binary: called CC=3 SCAR=11.1
Pod documented
76 13 my $self = shift;
77  
78 13 ▶ return defined $self->charset() && $self->charset() ne 'binary' ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->charset && $self->charset ne 'binary' ? : 6 7 13
Condition66%2/3
defined $self->charset and $self->charset ne "binary"
!ll&&!rl&&r
706
MC/DC50%1/2
defined $self->charset and $self->charset ne "binary"
defined $self->charset $self->charset ne "binary"
Truth table66%2/3
A and B
A= defined $self->charsetB= $self->charset ne "binary"
ABresult
0X0
100
111
79 }
80  
81 9 __PACKAGE__->meta()->make_immutable();
82  
83 9 1;
84  
85 # ABSTRACT: The content type for an email part
86  
87 __END__
« Courriel/Role/HeaderWithAttributes.pm ↑ Summary Courriel/Role/Part.pm »