DAIA/Entity.pm

filter: Statementstmt 80.0% 24 / 30 Branchbran 43.7% 7 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 88.8% 8 / 9 Podpod 100% 1 / 1 totaltotal 65.5% 40 / 61 CC 10 SCAR 27.2
CC
10
Cov
63%
rdfhash
42.0
__ANON__
2.1
__ANON__
2.0
CRAP 15.1
« DAIA/Item.pm ↑ Summary DAIA/Message.pm »
1 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package DAIA::Entity;
4 #ABSTRACT: Abstract base class of Department, Institution, Storage, and Limitation
5 11 our $VERSION = '0.43'; #VERSION
6  
7 11 ▶use Data::Validate::URI qw(is_uri is_web_uri);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use base 'DAIA::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 our %PROPERTIES = (
11 content => {
12 default => '',
13 53 ▶ filter => sub { defined $_[0] ? "$_[0]" : "" },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 53 0 53
14 },
15 href => {
16 26 ▶ filter => sub { my $v = "$_[0]"; $v =~ s/^\s+|\s$//g; is_web_uri($v) ? $v : undef; },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
is_web_uri($v) ? : 22 4 26
17 },
18 id => {
19 29 ▶ filter => sub { my $v = "$_[0]"; $v =~ s/^\s+|\s$//g; is_uri($v) ? $v : undef; }
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
is_uri($v) ? : 25 4 29
20 }
21 11 );
22  
23 42 ▶sub _buildargs {
Subroutine _buildargs: called CC=2 SCAR=6.9
24 42 shift;
25 42 ▶ return @_ % 2 ? (content => @_) : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 ? : 23 19 42
26 }
27  
28 0 ▶sub rdfhash {
Subroutine rdfhash: not called CC=6 SCAR=37.4
Pod documented
29 0 my $self = shift;
30  
31 # plain literal
32 return { type => 'literal', value => $self->{content} }
33 0 ▶ unless $self->{id} or $self->{href};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"id"} or $self->{"href"} 0 0 0
Condition0%0/3
$self->{"id"} or $self->{"href"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"id"} or $self->{"href"}
$self->{"id"} $self->{"href"}
Truth table0%0/3
A or B
A= $self->{"id"}B= $self->{"href"}
ABresult
1X1
011
000
34  
35 0 ▶ my $me = { 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' => [{
Branch: 1 branch
BranchTrueFalseTotal
if $self->rdftype 0 0 0
36 type => 'uri', value => $self->rdftype
37 }] } if $self->rdftype ;
38  
39 $me->{'http://www.w3.org/2000/01/rdf-schema#label'} = [{
40 value => $self->{content}, type => 'literal'
41 0 ▶ }] if $self->{content};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"content"} 0 0 0
42  
43 $me->{'http://xmlns.com/foaf/0.1/page'} = [{
44 value => $self->{href}, type => 'uri'
45 0 ▶ }] if $self->{href};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"href"} 0 0 0
46
47 0 return { $self->rdfuri => $me };
48 }
49  
50 11 1;
51  
52 __END__
« DAIA/Item.pm ↑ Summary DAIA/Message.pm »