Articulate/Enrichment/DateCreated.pm

filter: Statementstmt 100% 23 / 23 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 88.8% 32 / 36 CC 2 SCAR 2.3
CC
2
Cov
92%
enrich
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Articulate/Role/Component.pm ↑ Summary Articulate/Augmentation.pm »
1 package Articulate::Enrichment::DateCreated;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 ▶use Text::Markdown;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶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 5 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 sub _now {
23 2 ▶ DateTime->now;
Subroutine _now: called CC=1 SCAR=0.0
24 }
25  
26 sub enrich {
27 2 ▶ my $self = shift;
Subroutine enrich: called CC=2 SCAR=7.1
Pod documented
28 2 my $item = shift;
29 2 my $request = shift;
30 2 my $now = _now;
31 2 ▶ $item->meta->{schema}->{core}->{dateCreated} //= "$now";
Condition33%1/3
$item->meta->{"schema"}{"core"}{"dateCreated"} //= "$now"
l!l&&r!l&&!r
020
MC/DC0%0/2
$item->meta->{"schema"}{"core"}{"dateCreated"} //= "$now"
$item->meta->{"schema"}{"core"}{"dateCreated"} "$now"
Truth table33%1/3
A //= B
A= $item->meta->{"schema"}{"core"}{"dateCreated"}B= "$now"
ABresult
1X1
011
000
32 2 return $item;
33 }
34  
35 5 1;
« Articulate/Role/Component.pm ↑ Summary Articulate/Augmentation.pm »