Directory/Entry/Affiliation.pm

filter: Statementstmt 85.3% 35 / 41 Branchbran 33.3% 2 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 72.7% 8 / 11 Podpod 100% 2 / 2 totaltotal 73.8% 48 / 65 CC 5 SCAR 9.5
CC
5
Cov
76%
stringify
6.0
BUILDARGS
4.4
__ANON__
1.1
CRAP 2.6
« Directory.pm ↑ Summary Directory/Exception.pm »
1 package WWW::USF::Directory::Entry::Affiliation;
2  
3 2 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 ###########################################################################
8 # METADATA
9 2 our $AUTHORITY = 'cpan:DOUGDUDE';
10 2 our $VERSION = '0.003001';
11  
12 ###########################################################################
13 # MOOSE
14 2 ▶use Moose 0.89;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use MooseX::StrictConstructor 0.08;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 ###########################################################################
18 # MOOSE TYPES
19 2 ▶use MooseX::Types::Common::String qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
20 NonEmptySimpleStr
21 2 );
22  
23 ###########################################################################
24 # ALL IMPORTS BEFORE THIS WILL BE ERASED
25 2 ▶use namespace::clean 0.04 -except => [qw(meta)];
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 ###########################################################################
28 # OVERLOADED FUNCTIONS
29 2 ▶__PACKAGE__->meta->add_package_symbol(q{&()} => sub { });
Subroutine __ANON__: not called CC=1 SCAR=0.0
30 0 ▶__PACKAGE__->meta->add_package_symbol(q{&(""} => sub { shift->stringify });
Subroutine __ANON__: not called CC=1 SCAR=1.2
31  
32 ###########################################################################
33 # ATTRIBUTES
34 2 has 'department' => (
35 is => 'ro',
36 isa => NonEmptySimpleStr,
37  
38 documentation => q{The department this role is in},
39 clearer => '_clear_department',
40 predicate => 'has_department',
41 );
42 2 has 'role' => (
43 is => 'ro',
44 isa => NonEmptySimpleStr,
45  
46 documentation => q{The role of the person in the department},
47 required => 1,
48 );
49  
50 ###########################################################################
51 # METHODS
52 0 ▶sub stringify {
Subroutine stringify: not called CC=2 SCAR=17.9
Pod documented
53 # The default stringify method returns role: department or role
54 0 my ($self) = @_;
55  
56 # Start the string with the role
57 0 my $string = $self->role;
58  
59 0 ▶ if ($self->has_department) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_department) 0 0 0
60 # Add on the department
61 0 $string .= ': ' . $self->department;
62 }
63  
64 0 return $string;
65 }
66  
67 ###########################################################################
68 # CONSTRUCTOR
69 3 ▶sub BUILDARGS {
Subroutine BUILDARGS: called CC=4 SCAR=14.8
Pod documented
70 3 my ($class, @args) = @_;
71  
72 3 ▶ if (@args == 1 && ref $args[0] eq q{}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args == 1 and ref $args[0] eq "") 3 0 3
Condition33%1/3
@args == 1 and ref $args[0] eq ""
!ll&&!rl&&r
003
MC/DC0%0/2
@args == 1 and ref $args[0] eq ""
@args == 1 ref $args[0] eq ""
Truth table33%1/3
A and B
A= @args == 1B= ref $args[0] eq ""
ABresult
0X0
100
111
73 # It looks like a single string was passed to the constructor, so
74 # parse the string.
75 3 my ($role, $department) = $args[0] =~ m{\A (.+?) (?: \s+ : \s+ (.+?) )? \z}msx;
76  
77 # Set the new arguments with the role
78 3 @args = (role => $role);
79  
80 3 ▶ if (defined $department) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $department) 3 0 3
81 # Add the department if defined
82 3 push @args, department => $department;
83 }
84 }
85  
86 # Continue building
87 3 return $class->SUPER::BUILDARGS(@args);
88 }
89  
90 ###########################################################################
91 # MAKE MOOSE OBJECT IMMUTABLE
92 2 __PACKAGE__->meta->make_immutable;
93  
94 2 1;
95  
96 __END__
« Directory.pm ↑ Summary Directory/Exception.pm »