File Coverage

blib/lib/WebService/SSLLabs/Host.pm
Criterion Covered Total %
statement 9 61 14.7
branch 0 14 0.0
condition 0 3 0.0
subroutine 3 18 16.6
pod 15 15 100.0
total 27 111 24.3


line stmt bran cond sub pod time code
1             package WebService::SSLLabs::Host;
2              
3 3     3   27 use strict;
  3         7  
  3         86  
4 3     3   14 use warnings;
  3         5  
  3         69  
5 3     3   1251 use WebService::SSLLabs::Endpoint();
  3         8  
  3         2239  
6              
7             our $VERSION = '0.31';
8              
9             sub new {
10 0     0 1   my ( $class, $json ) = @_;
11 0           my $self = $json;
12 0 0         if ( defined $self->{endpoints} ) {
13 0           my @endpoints = @{ $self->{endpoints} };
  0            
14 0           $self->{endpoints} = [];
15 0           foreach my $endpoint (@endpoints) {
16 0           push @{ $self->{endpoints} },
  0            
17             WebService::SSLLabs::Endpoint->new($endpoint);
18             }
19             }
20             else {
21 0           $self->{endpoints} = [];
22             }
23 0           bless $self, $class;
24 0           return $self;
25             }
26              
27             sub ready {
28 0     0 1   my ($self) = @_;
29 0 0         if ( $self->status() =~ /^READY$/smxi ) {
30 0           return $self;
31             }
32             else {
33 0           return;
34             }
35             }
36              
37             sub complete {
38 0     0 1   my ($self) = @_;
39 0 0         if ( $self->status() =~ /^READY|ERROR$/smxi ) {
40 0           return $self;
41             }
42             else {
43 0           return;
44             }
45             }
46              
47             sub eta {
48 0     0 1   my ($self) = @_;
49 0           my $host_eta;
50 0           foreach my $endpoint ( $self->endpoints() ) {
51 0 0 0       if ( ( defined $endpoint->eta() )
52             && ( $endpoint->eta() =~ /^\d+$/smx ) )
53             {
54 0 0         if ( !defined $host_eta ) {
55 0           $host_eta = $endpoint->eta();
56             }
57 0 0         if ( $endpoint->eta() >= $host_eta ) {
58 0           $host_eta = $endpoint->eta();
59             }
60             }
61             }
62 0           return $host_eta;
63             }
64              
65             sub status {
66 0     0 1   my ($self) = @_;
67 0           return $self->{status};
68             }
69              
70             sub status_message {
71 0     0 1   my ($self) = @_;
72 0           return $self->{statusMessage};
73             }
74              
75             sub endpoints {
76 0     0 1   my ($self) = @_;
77 0           return @{ $self->{endpoints} };
  0            
78             }
79              
80             sub host {
81 0     0 1   my ($self) = @_;
82 0           return $self->{host};
83             }
84              
85             sub port {
86 0     0 1   my ($self) = @_;
87 0           return $self->{port};
88             }
89              
90             sub start_time {
91 0     0 1   my ($self) = @_;
92 0           return $self->{startTime};
93             }
94              
95             sub criteria_version {
96 0     0 1   my ($self) = @_;
97 0           return $self->{criteriaVersion};
98             }
99              
100             sub engine_version {
101 0     0 1   my ($self) = @_;
102 0           return $self->{engineVersion};
103             }
104              
105             sub is_public {
106 0     0 1   my ($self) = @_;
107 0 0         return $self->{isPublic} ? 1 : 0;
108             }
109              
110             sub protocol {
111 0     0 1   my ($self) = @_;
112 0           return $self->{protocol};
113             }
114              
115             sub test_time {
116 0     0 1   my ($self) = @_;
117 0           return $self->{testTime};
118             }
119              
120             1;
121             __END__