ZofCMS/Plugin/GetRemotePageTitle.pm

filter: Statementstmt 42.4% 14 / 33 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 57.1% 4 / 7 Podpod n/a totaltotal 32.7% 18 / 55 CC 8 SCAR 37.3
CC
8
Cov
30%
_do
72.0
_key
2.0
_defaults
2.0
CRAP 41.7
« ZofCMS/Plugin/FormToDatabase.pm ↑ Summary ZofCMS/Plugin/DataToExcel.pm »
1 package App::ZofCMS::Plugin::GetRemotePageTitle;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.001010'; # VERSION
7  
8 1 ▶use base 'App::ZofCMS::Plugin::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use WWW::GetPageTitle;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub _key {
Subroutine _key: not called CC=1 SCAR=6.9
12 0 'plug_get_remote_page_title'
13 }
14 0 ▶sub _defaults {
Subroutine _defaults: not called CC=1 SCAR=6.9
15 0 ua => LWP::UserAgent->new(
16 agent => "Opera 9.5",
17 timeout => 30,
18 max_size => 2000,
19 ),
20 uri => undef,
21 }
22 0 ▶sub _do {
Subroutine _do: not called CC=8 SCAR=42.8
23 0 my ( $self, $conf, $t, $q, $config ) = @_;
24  
25 $conf->{uri} = $conf->{uri}->( $t, $q, $config )
26 0 ▶ if ref $conf->{uri} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $conf->{"uri"} eq "CODE" 0 0 0
27  
28 return
29 unless defined $conf->{uri}
30 0 ▶ and length $conf->{uri};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"uri"} and length $conf->{"uri"} 0 0 0
Condition0%0/3
defined $conf->{"uri"} and length $conf->{"uri"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $conf->{"uri"} and length $conf->{"uri"}
defined $conf->{"uri"} length $conf->{"uri"}
Truth table0%0/3
A and B
A= defined $conf->{"uri"}B= length $conf->{"uri"}
ABresult
0X0
100
111
31  
32  
33 0 my $title = WWW::GetPageTitle->new( ua => $conf->{ua} );
34  
35 0 ▶ if ( ref $conf->{uri} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $conf->{'uri'} eq 'ARRAY') { } 0 0 0
36 0 my @results;
37  
38 0 for ( @{ $conf->{uri} } ) {
39 0 my $page_title = $title->get_title( $_ );
40  
41 0 ▶ if ( defined $page_title ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $page_title) { } 0 0 0
42 0 push @results, { title => $page_title };
43 }
44 else {
45 0 push @results, { error => $title->error };
46 }
47  
48 0 $t->{t}{plug_remote_page_title} = \@results;
49 }
50 }
51 else {
52 0 my $page_title = $title->get_title( $conf->{uri} );
53 0 ▶ if ( defined $page_title ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $page_title) { } 0 0 0
54 0 $t->{t}{plug_remote_page_title} = $page_title;
55 }
56 else {
57 0 $t->{t}{plug_remote_page_title_error} = $title->error;
58 }
59 }
60 }
61  
62 1 1;
63 __END__
« ZofCMS/Plugin/FormToDatabase.pm ↑ Summary ZofCMS/Plugin/DataToExcel.pm »