Phylo/Identifiable.pm

filter: Statementstmt 86.9% 20 / 23 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 3 / 3 totaltotal 85.7% 30 / 35 CC 2 SCAR 3.5
CC
2
Cov
84%
get_id
2.1
is_equal
2.0
BEGIN
1.0
CRAP 1.4
« Phylo/Util/IDPool.pm ↑ Summary Phylo/Util/Dependency.pm »
1 package Bio::Phylo::Identifiable;
2 57 ▶use Bio::Phylo::Util::IDPool;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 57 ▶use Bio::Phylo::Util::Exceptions 'throw';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 57 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 57 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Bio::Phylo::Identifiable - Objects with unique identifiers
11  
12 =head1 SYNOPSIS
13  
14 # Actually, you would almost never use this module directly. This is
15 # the base class for other modules.
16 use Bio::Phylo::Identifiable;
17
18 my $obj = Bio::Phylo::Identifiable->new;
19 print $obj->get_id;
20  
21  
22 =head1 DESCRIPTION
23  
24 This is the base class for objects in the Bio::Phylo package
25 that need unique identifiers.
26  
27 =head1 METHODS
28  
29 =head2 CONSTRUCTOR
30  
31 =over
32  
33 =item new()
34  
35 Type : Constructor
36 Title : new
37 Usage : my $phylo = Bio::Phylo::Identifiable->new;
38 Function: Instantiates Bio::Phylo::Identifiable object
39 Returns : a Bio::Phylo::Identifiable object
40 Args : NONE
41  
42 =cut
43  
44 12924 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
45 12924 my $class = shift;
46  
47 # happens only and exactly once because this
48 # root class is visited from every constructor
49 12924 my $self = Bio::Phylo::Util::IDPool->_initialize();
50  
51 # bless in child class, not __PACKAGE__
52 12924 bless $self, $class;
53 12924 return $self;
54 }
55  
56 =item get_id()
57  
58 Gets invocant's UID.
59  
60 Type : Accessor
61 Title : get_id
62 Usage : my $id = $obj->get_id;
63 Function: Returns the object's unique ID
64 Returns : INT
65 Args : None
66  
67 =cut
68  
69 2521560 ▶sub get_id {
Subroutine get_id: called CC=2 SCAR=7.6
Pod documented
70 2521560 my ($self) = @_;
71 2521560 ▶ if ( UNIVERSAL::isa( $self, 'SCALAR' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($self, 'SCALAR')) { } 2521560 0 2521560
72 2521560 return $$self;
73 }
74 else {
75 0 throw 'API' => "Not a SCALAR reference";
76 }
77 }
78  
79 =item is_equal()
80  
81 Compares invocant's UID with argument's UID
82  
83 Type : Test
84 Title : is_equal
85 Usage : do_something() if $obj->is_equal($other);
86 Function: Compares objects by UID
87 Returns : BOOLEAN
88 Args : Another object to compare with
89  
90 =cut
91  
92 0 ▶sub is_equal {
Subroutine is_equal: not called CC=1 SCAR=6.9
Pod documented
93 0 my ($self,$other) = @_;
94 0 return $self->get_id == $other->get_id;
95 }
96  
97 =back
98  
99 =head1 SEE ALSO
100  
101 There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo>
102 for any user or developer questions and discussions.
103  
104 Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>
105  
106 =head1 CITATION
107  
108 If you use Bio::Phylo in published research, please cite it:
109  
110 B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen>
111 and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl.
112 I<BMC Bioinformatics> B<12>:63.
113 L<http://dx.doi.org/10.1186/1471-2105-12-63>
114  
115 =cut
116  
117 57 1;
« Phylo/Util/IDPool.pm ↑ Summary Phylo/Util/Dependency.pm »