| 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::Message; | ||||||||||||||||||||||||||||||||||
| 4 | #ABSTRACT: An optional information or error message | ||||||||||||||||||||||||||||||||||
| 5 | 11 | our $VERSION = '0.43'; #VERSION | |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 11 | ▶ | use base 'DAIA::Object'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | 11 | our $DEFAULT_LANG = 'en'; | |||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | our %PROPERTIES = ( | ||||||||||||||||||||||||||||||||||
| 12 | content => { | ||||||||||||||||||||||||||||||||||
| 13 | default => '', | ||||||||||||||||||||||||||||||||||
| 14 | 64 | ▶ | filter => sub { "$_[0]" } # stringify everything | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | }, | ||||||||||||||||||||||||||||||||||
| 16 | lang => { | ||||||||||||||||||||||||||||||||||
| 17 | 43 | ▶ | default => sub { $DEFAULT_LANG }, | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 18 | 28 | ▶ | filter => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 19 | 28 | ▶ | is_language_tag("$_[0]") ? lc("$_[0]") : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 20 | }, | ||||||||||||||||||||||||||||||||||
| 21 | }, | ||||||||||||||||||||||||||||||||||
| 22 | errno => { | ||||||||||||||||||||||||||||||||||
| 23 | default => undef, | ||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | filter => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | return unless defined $_[0]; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | $_[0] =~ m/^-?\d+$/ ? $_[0] : 0 | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 27 | }, | ||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||
| 29 | 11 | ); | |||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | # called by the constructor | ||||||||||||||||||||||||||||||||||
| 32 | 55 | ▶ | sub _buildargs { | ||||||||||||||||||||||||||||||||
|
Subroutine
_buildargs: called CC=7 SCAR=20.0
| |||||||||||||||||||||||||||||||||||
| 33 | 55 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 34 | 55 | ▶ | if ( @_ % 2 ) { # content as first parameter | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 35 | 42 | my ($content, %p) = @_; | |||||||||||||||||||||||||||||||||
| 36 | 42 | ▶ | if ( @_ == 3 and not defined $PROPERTIES{$_[1]} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 3 and not defined $DAIA::Message::PROPERTIES{$_[1]}
MC/DC0%0/2
@_ == 3 and not defined $DAIA::Message::PROPERTIES{$_[1]}
@_ == 3
not defined $DAIA::Message::PROPERTIES{$_[1]}
Truth table66%2/3
A and not(B)
A= @_ == 3B= not defined $DAIA::Message::PROPERTIES{$_[1]}
| |||||||||||||||||||||||||||||||||||
| 37 | 0 | return ( lang => $_[0], content => $_[1] ); | |||||||||||||||||||||||||||||||||
| 38 | } else { | ||||||||||||||||||||||||||||||||||
| 39 | 42 | return ( content => $content, %p ); | |||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||
| 41 | ▶ | } elsif ( defined $_[0] and not defined $PROPERTIES{$_[0]} and is_language_tag($_[0]) ) { | |||||||||||||||||||||||||||||||||
|
Condition83%5/6
defined $_[0] and not defined $DAIA::Message::PROPERTIES{$_[0]} and is_language_tag($_[0])
defined $_[0] and not defined $DAIA::Message::PROPERTIES{$_[0]}
MC/DC66%2/3
defined $_[0] and not defined $DAIA::Message::PROPERTIES{$_[0]} and is_language_tag($_[0])
defined $_[0]
not defined $DAIA::Message::PROPERTIES{$_[0]}
is_language_tag($_[0])
Truth table75%3/4
A and not(B) and C
A= defined $_[0]B= not defined $DAIA::Message::PROPERTIES{$_[0]}C= is_language_tag($_[0])
| |||||||||||||||||||||||||||||||||||
| 42 | 5 | my ($lang, $content, %p) = @_; | |||||||||||||||||||||||||||||||||
| 43 | 5 | return ( lang => $lang, content => $content, %p ); | |||||||||||||||||||||||||||||||||
| 44 | } else { | ||||||||||||||||||||||||||||||||||
| 45 | 8 | return @_; | |||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||
| 48 | 0 | return @_; | |||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub rdfhash { | ||||||||||||||||||||||||||||||||
|
Subroutine
rdfhash: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 52 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 53 | 0 | my $rdf = { type => 'literal', value => $self->{content} }; | |||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | $rdf->{lang} = $self->{lang} if $self->{lang}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 55 | 0 | return $rdf; | |||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||
| 58 | 33 | ▶ | sub is_language_tag { | ||||||||||||||||||||||||||||||||
|
Subroutine
is_language_tag: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 59 | 33 | my($tag) = lc($_[0]); | |||||||||||||||||||||||||||||||||
| 60 | 33 | return $tag =~ /^[a-z]{1,8}(-[a-z0-9]{1,8})*$/; | |||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||
| 63 | 11 | 1; | |||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||
| 65 | __END__ | ||||||||||||||||||||||||||||||||||