Mattermost/V4/API/Object/Role/BelongingToUser.pm

filter: Statementstmt 94.4% 17 / 18 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 83.3% 5 / 6 Podpod n/a totaltotal 71.4% 25 / 35 CC 4 SCAR 8.7
CC
4
Cov
77%
_build_creator_id
4.1
_build_created_by
2.0
_build_user
2.0
CRAP 2.4
« Mattermost/V4/API/Object/File.pm ↑ Summary Mattermost/V4/API/Object/Binary.pm »
1 package WebService::Mattermost::V4::API::Object::Role::BelongingToUser;
2  
3 # ABSTRACT: Mark an object as belonging to a user.
4  
5 12 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use Types::Standard qw(InstanceOf Maybe Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 12 ▶use WebService::Mattermost::Helper::Alias 'view';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 ################################################################################
11  
12 12 has creator_id => (is => 'ro', isa => Maybe[Str], lazy => 1, builder => 1);
13 12 has [ qw(user created_by) ] => (is => 'ro', isa => Maybe[InstanceOf[view 'User']], lazy => 1, builder => 1);
14  
15 ################################################################################
16  
17 sub _build_creator_id {
18 1 ▶ my $self = shift;
Subroutine _build_creator_id: called CC=3 SCAR=14.2
19  
20 return $self->raw_data->{creator_id}
21 || $self->raw_data->{owner_id}
22 1 ▶ || $self->raw_data->{user_id};
Condition33%2/6
$self->raw_data->{'creator_id'} || $self->raw_data->{'owner_id'} || $self->raw_data->{'user_id'}
l!l&&r!l&&!r
100
$self->raw_data->{"creator_id"} or $self->raw_data->{"owner_id"}
l!l&&r!l&&!r
010
MC/DC0%0/3
$self->raw_data->{'creator_id'} || $self->raw_data->{'owner_id'} || $self->raw_data->{'user_id'}
$self->raw_data->{"creator_id"} $self->raw_data->{"owner_id"} $self->raw_data->{'user_id'}
Truth table25%1/4
A or B || C
A= $self->raw_data->{"creator_id"}B= $self->raw_data->{"owner_id"}C= $self->raw_data->{'user_id'}
ABCresult
1XX1
01X1
0011
0000
23 }
24  
25 sub _build_created_by {
26 1 ▶ my $self = shift;
Subroutine _build_created_by: called CC=2 SCAR=7.1
27  
28 1 ▶ return unless $self->creator_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->creator_id 0 1 1
29 1 return $self->api->user->get($self->creator_id)->item;
30 }
31  
32 0 ▶sub _build_user { shift->created_by }
Subroutine _build_user: not called CC=1 SCAR=6.9
33  
34 ################################################################################
35  
36 12 1;
37  
38 __END__
39  
40 =pod
41  
42 =encoding UTF-8
43  
44 =head1 NAME
45  
46 WebService::Mattermost::V4::API::Object::Role::BelongingToUser - Mark an object as belonging to a user.
47  
48 =head1 VERSION
49  
50 version 0.28
51  
52 =head1 DESCRIPTION
53  
54 Link a view object to its creator.
55  
56 =head2 ATTRIBUTES
57  
58 =over 4
59  
60 =item C<creator_id>
61  
62 The creator's string ID.
63  
64 =item C<created_by|user>
65  
66 Linked L<WebService::Mattermost::V4::API::Object::User> object.
67  
68 =back
69  
70 =head1 AUTHOR
71  
72 Mike Jones <mike@netsplit.org.uk>
73  
74 =head1 COPYRIGHT AND LICENSE
75  
76 This software is Copyright (c) 2020 by Mike Jones.
77  
78 This is free software, licensed under:
79  
80 The MIT (X11) License
81  
82 =cut
« Mattermost/V4/API/Object/File.pm ↑ Summary Mattermost/V4/API/Object/Binary.pm »