Bug 16136: Koha::Patron contains 'return undef' and fails critic tests
[koha.git] / Koha / Patron.pm
1 package Koha::Patron;
2
3 # Copyright ByWater Solutions 2014
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20 use Modern::Perl;
21
22 use Carp;
23
24 use Koha::Database;
25 use Koha::Patron::Images;
26
27 use base qw(Koha::Object);
28
29 =head1 NAME
30
31 Koha::Patron - Koha Patron Object class
32
33 =head1 API
34
35 =head2 Class Methods
36
37 =cut
38
39 =head3 guarantor
40
41 Returns a Koha::Patron object for this patron's guarantor
42
43 =cut
44
45 sub guarantor {
46     my ( $self ) = @_;
47
48     return unless $self->guarantorid();
49
50     return Koha::Patrons->find( $self->guarantorid() );
51 }
52
53 sub image {
54     my ( $self ) = @_;
55
56     return Koha::Patron::Images->find( $self->borrowernumber )
57 }
58
59 =head3 guarantees
60
61 Returns the guarantees (list of Koha::Patron) of this patron
62
63 =cut
64
65 sub guarantees {
66     my ( $self ) = @_;
67
68     return Koha::Patrons->search({ guarantorid => $self->borrowernumber });
69 }
70
71 =head3 siblings
72
73 Returns the siblings of this patron.
74
75 =cut
76
77 sub siblings {
78     my ( $self ) = @_;
79
80     my $guarantor = $self->guarantor;
81
82     return unless $guarantor;
83
84     return Koha::Patrons->search(
85         {
86             guarantorid => {
87                 '!=' => undef,
88                 '=' => $guarantor->id,
89             },
90             borrowernumber => {
91                 '!=' => $self->borrowernumber,
92             }
93         }
94     );
95 }
96
97 =head3 type
98
99 =cut
100
101 sub _type {
102     return 'Borrower';
103 }
104
105 =head1 AUTHOR
106
107 Kyle M Hall <kyle@bywatersolutions.com>
108
109 =cut
110
111 1;