Articulate/Enrichment/DateCreated.pm

filter: Statementstmt 100% 23 / 23 Branchbran n/a Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 94.1% 32 / 34 CC 2 SCAR 2.2
CC
2
Cov
96%
enrich
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Articulate/Sortation/Numeric.pm ↑ Summary Articulate/Service/LoginForm.pm »
1 package Articulate::Enrichment::DateCreated;
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 6 ▶use Text::Markdown;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Articulate::Enrichment::DateCreated - add a creation date to the meta
11  
12 =head1 METHODS
13  
14 =head3 enrich
15  
16 Sets the creation date (C<meta.schema.core.dateCreated>) to the current time, unless it already has a defined value.
17  
18 =cut
19  
20 6 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 2 ▶sub _now {
Subroutine _now: called CC=1 SCAR=0.0
23 2 DateTime->now;
24 }
25  
26 2 ▶sub enrich {
Subroutine enrich: called CC=2 SCAR=7.0
Pod documented
27 2 my $self = shift;
28 2 my $item = shift;
29 2 my $request = shift;
30 2 my $now = _now;
31 2 ▶ $item->meta->{schema}->{core}->{dateCreated} //= "$now";
Condition50%1/2
$item->meta->{"schema"}{"core"}{"dateCreated"} //= "$now"
l!l
02
MC/DC0%0/1
$item->meta->{"schema"}{"core"}{"dateCreated"} //= "$now"
$item->meta->{"schema"}{"core"}{"dateCreated"}
Truth table50%1/2
A
A= $item->meta->{"schema"}{"core"}{"dateCreated"}
Aresult
11
00
32 2 return $item;
33 }
34  
35 6 1;
« Articulate/Sortation/Numeric.pm ↑ Summary Articulate/Service/LoginForm.pm »