Enbld/Target/Attribute/SortedVersionList.pm

filter: Statementstmt 78.0% 39 / 50 Branchbran 37.5% 3 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 3 totaltotal 72.8% 51 / 70 SCAR 19.1
CC
6
Cov
72%
validate
5.4
initialize
3.7
BEGIN
1.0
CRAP 6.8
« Enbld/Target/Attribute/VersionCondition.pm ↑ Summary Enbld/Message.pm »
1 package Enbld::Target::Attribute::SortedVersionList;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use parent qw/Enbld::Target::AttributeExtension::Word/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 require Enbld::Exception;
12  
13 sub initialize {
14 49 ▶ my ( $self, $param ) = @_;
Subroutine initialize: called CC=3 SCAR=13.0
Pod undocumented
15  
16 49 ▶ if ( ! defined $param ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $param) 49 0 49
17 $self->{callback} = sub {
18 35 ▶ my $attributes = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
19  
20 35 my $list = $attributes->VersionList;
21  
22 my @sorted = sort {
23 34 version->declare( $a ) cmp version->declare( $b )
24 35 } @{ $list };
25  
26 35 return \@sorted;
27 49 };
28  
29 49 return $self;
30 };
31  
32 0 ▶ if ( $param ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($param) 0 0 0
33 0 $self->SUPER::initialize( $param );
34 0 return $self;
35 }
36  
37 0 my $err = "Attribute 'SortedVersionList' isn't defined";
38 0 croak( Enbld::Exception->new( $err ));
39 }
40  
41 sub validate {
42 39 ▶ my ( $self, $value ) = @_;
Subroutine validate: called CC=4 SCAR=16.9
Pod undocumented
43  
44 39 ▶ unless ( ref( $value ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $value eq "ARRAY") 0 39 39
45 0 my $type = ref( $self );
46 0 $type =~ s/.*:://;
47  
48 0 my $err = "Attribute 'SortedVersionList' isn't ARRAY reference";
49 0 croak( Enbld::Exception->new( $err, $value ));
50 }
51  
52 39 ▶ if ( ! @{ $value } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@{$value;}) 0 39 39
53 0 my $err = "Attribute 'SortedVersionList' is no version list";
54 0 croak( Enbld::Exception->new( $err ));
55 }
56  
57 39 foreach my $string ( @{ $value } ) {
58 77 $self->SUPER::validate( $string );
59 }
60  
61 39 return $value;
62 }
63  
64 sub to_value {
65 39 ▶ my $self = shift;
Subroutine to_value: called CC=1 SCAR=0.0
Pod undocumented
66  
67 39 my $value = $self->evaluate;
68  
69 39 $self->validate( $value );
70  
71 39 return $value;
72 }
73  
74 3 1;
« Enbld/Target/Attribute/VersionCondition.pm ↑ Summary Enbld/Message.pm »