blib/lib/XML/Compile/WSS/Timestamp.pm

filter: Statementstmt 91.2% 52 / 57 Branchbran 40.0% 4 / 10 Conditioncond 37.5% 3 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 80.0% 12 / 15 Podpod 75.0% 6 / 8 totaltotal 74.7% 77 / 103 CC 9 SCAR 12.6
CC
9
Cov
79%
timestamps
8.8
init
3.1
prepareWriting
2.0
CRAP 3.5
« lib/XML/Compile/WSS.pm ↑ Summary lib/XML/Compile/WSS/Util.pm »
1 # Copyrights 2011-2017 by [Mark Overmeer].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.02.
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package XML::Compile::WSS::Timestamp;
9 2 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 $VERSION = '1.14';
11  
12 2 ▶use base 'XML::Compile::WSS';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use Log::Report 'xml-compile-wss';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 ▶use XML::Compile::WSS::Util qw/WSU_10/;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 sub init($)
20 2 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=3 SCAR=11.3
Pod undocumented
21 2 ▶ $args->{wss_version} ||= '1.1';
Condition50%1/2
$args->{"wss_version"} ||= "1.1"
l!l
02
MC/DC0%0/1
$args->{"wss_version"} ||= "1.1"
$args->{"wss_version"}
Truth table50%1/2
A
A= $args->{"wss_version"}
Aresult
11
00
22 2 $self->SUPER::init($args);
23  
24 2 $self->{XCWT_created} = $args->{created};
25 2 $self->{XCWT_expires} = $args->{expires};
26 2 $self->{XCWT_lifetime} = $args->{lifetime};
27 2 ▶ $self->{XCWT_wsu_id} = $args->{wsu_Id} || $args->{wsu_id};
Condition33%1/3
$args->{'wsu_Id'} || $args->{'wsu_id'}
l!l&&r!l&&!r
200
MC/DC0%0/2
$args->{'wsu_Id'} || $args->{'wsu_id'}
$args->{'wsu_Id'} $args->{'wsu_id'}
Truth table33%1/3
A || B
A= $args->{'wsu_Id'}B= $args->{'wsu_id'}
ABresult
1X1
011
000
28 2 $self;
29 }
30  
31 #----------------------------------
32  
33 0 ▶sub created() {shift->{XCWT_created}}
Subroutine created: not called CC=1 SCAR=6.9
Pod documented
34 0 ▶sub expires() {shift->{XCWT_expires}}
Subroutine expires: not called CC=1 SCAR=6.9
Pod documented
35 0 ▶sub lifetime() {shift->{XCWT_lifetime}}
Subroutine lifetime: not called CC=1 SCAR=6.9
Pod documented
36 3 ▶sub wsuId() {shift->{XCWT_wsu_id}}
Subroutine wsuId: called CC=1 SCAR=0.0
Pod documented
37  
38  
39 sub timestamps()
40 3 ▶{ my $self = shift;
Subroutine timestamps: called CC=6 SCAR=21.8
Pod documented
41 3 my ($c, $e, $l) = @{$self}{ qw/XCWT_created XCWT_expires XCWT_lifetime/ };
42 3 my ($expires);
43  
44 3 ▶ defined $c or $c = time;
Branch: 1 branch
BranchTrueFalseTotal
defined $c or $c = time 3 0 3
45 3 ▶ my $created = $c eq '' ? undef : $self->dateTime($c);
Branch: 1 branch
BranchTrueFalseTotal
$c eq '' ? : 0 3 3
46  
47 3 ▶ if(!$e && defined $l)
Branch: 1 branch
BranchTrueFalseTotal
if (not $e and defined $l) 0 3 3
Condition33%1/3
not $e and defined $l
!ll&&!rl&&r
300
MC/DC0%0/2
not $e and defined $l
not $e defined $l
Truth table33%1/3
not(A) and B
A= not $eB= defined $l
ABresult
0X0
100
111
48 0 ▶ { $c !~ m/\D/ or error "lifetime only when created is in seconds";
Branch: 1 branch
BranchTrueFalseTotal
$c =~ /\D/ and &error("lifetime only when created is in seconds") 0 0 0
49 0 $e = $c + $l;
50 }
51 3 ($created, $self->dateTime($e));
52 }
53  
54 sub prepareWriting($)
55 2 ▶{ my ($self, $schema) = @_;
Subroutine prepareWriting: called CC=2 SCAR=6.9
Pod undocumented
56 2 $self->SUPER::prepareWriting($schema);
57 2 ▶ return if $self->{XCWT_stamp};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"XCWT_stamp"} 0 2 2
58  
59 2 my $ts_type = $schema->findName('wsu:Timestamp') ;
60 2 my @hooks = $self->writerHookWsuId('wsu:TimestampType');
61 2 my $make_ts = $schema->writer($ts_type, include_namespaces => 1
62 , hooks => \@hooks);
63 2 $schema->prefixFor(WSU_10);
64  
65 3 ▶ $self->{XCWT_stamp} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
66 3 my ($doc, $data) = @_;
67 3 my ($created, $expires) = $self->timestamps;
68 3 $data->{$ts_type} = $make_ts->($doc,
69 { wsu_Id => $self->wsuId
70 , wsu_Created => $created
71 , wsu_Expires => $expires
72 });
73 3 $data;
74 2 };
75 }
76  
77 sub create($$)
78 3 ▶{ my ($self, $doc, $data) = @_;
Subroutine create: called CC=1 SCAR=0.0
Pod documented
79 3 $self->SUPER::create($doc, $data);
80 3 $self->{XCWT_stamp}->($doc, $data);
81 }
82  
83 2 1;
« lib/XML/Compile/WSS.pm ↑ Summary lib/XML/Compile/WSS/Util.pm »