File Coverage

blib/lib/Mail/Box/Collection.pm
Criterion Covered Total %
statement 28 38 73.6
branch 2 14 14.2
condition 1 2 50.0
subroutine 8 10 80.0
pod 3 4 75.0
total 42 68 61.7


line stmt bran cond sub pod time code
1             # This code is part of Perl distribution Mail-Box version 4.01.
2             # The POD got stripped from this file by OODoc version 3.05.
3             # For contributors see file ChangeLog.
4              
5             # This software is copyright (c) 2001-2025 by Mark Overmeer.
6              
7             # This is free software; you can redistribute it and/or modify it under
8             # the same terms as the Perl 5 programming language system itself.
9             # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10              
11              
12             package Mail::Box::Collection;{
13             our $VERSION = '4.01';
14             }
15              
16 3     3   91701 use parent qw/User::Identity::Collection Mail::Reporter/;
  3         6  
  3         19  
17              
18 3     3   33214 use strict;
  3         6  
  3         107  
19 3     3   14 use warnings;
  3         5  
  3         161  
20              
21 3     3   14 use Log::Report 'mail-box', import => [ qw// ];
  3         5  
  3         26  
22              
23 3     3   2078 use Mail::Box::Identity;
  3         10  
  3         121  
24              
25 3     3   20 use Scalar::Util qw/weaken/;
  3         6  
  3         1083  
26              
27             #--------------------
28              
29             sub new(@)
30 5     5 1 14 { my $class = shift;
31 5 50       27 unshift @_,'name' if @_ % 2;
32 5         36 $class->Mail::Reporter::new(@_);
33             }
34              
35             sub init($)
36 5     5 0 56 { my ($self, $args) = @_;
37 5   50     36 $args->{item_type} //= 'Mail::Box::Identity';
38              
39 5         21 $self->Mail::Reporter::init($args);
40 5         50 $self->User::Identity::Collection::init($args);
41              
42             weaken($self->{MBC_manager})
43 5 50       451 if $self->{MBC_manager} = delete $args->{manager};
44              
45 5         15 $self->{MBC_ftype} = delete $args->{folder_type};
46 5         28 $self;
47             }
48              
49             #--------------------
50              
51             sub type() { 'folders' }
52              
53              
54             sub manager()
55 0     0 1   { my $self = shift;
56             return $self->{MBC_manager}
57 0 0         if defined $self->{MBC_manager};
58              
59 0           my $parent = $self->parent;
60 0 0         defined $parent ? $self->parent->manager : undef;
61             }
62              
63              
64             sub folderType()
65 0     0 1   { my $self = shift;
66 0 0         return ($self->{MBC_ftype} = shift) if @_;
67 0 0         return $self->{MBC_ftype} if exists $self->{MBC_ftype};
68              
69 0 0         if(my $parent = $self->parent)
70 0           { return $self->{MBC_ftype} = $parent->folderType;
71             }
72              
73 0           undef;
74             }
75              
76             1;