Articulate/Service/SimpleForms.pm

filter: Statementstmt 33.9% 20 / 59 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 6 / 10 Podpod 0.0% 0 / 4 totaltotal 29.8% 26 / 87 CC 8 SCAR 21.5
CC
8
Cov
27%
handle_delete_form
20.0
handle_edit_form
12.0
handle_create_form
6.0
CRAP 8.6
« Articulate/Authentication.pm ↑ Summary Articulate/Authentication/Internal.pm »
1 package Articulate::Service::SimpleForms;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 ▶use Articulate::Syntax;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 with 'Articulate::Role::Service';
10  
11 6 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 0 ▶sub handle_create_form {
Subroutine handle_create_form: not called CC=2 SCAR=17.9
Pod undocumented
15 0 my $self = shift;
16 0 my $request = shift;
17 0 my $user = $request->user_id;
18 0 my $location = new_location $request->data->{location};
19 0 my $permission = $self->authorisation->permitted( $user, write => $location );
20  
21 0 ▶ if ($permission) {
Branch: 1 branch
BranchTrueFalseTotal
if ($permission) { } 0 0 0
22  
23 0 return new_response 'form/create', {
24 form => {
25 location => new_location $location, # as string or arrayref?
26 },
27 };
28 }
29 else {
30 0 throw_error Forbidden => $permission->reason;
31 }
32  
33 }
34  
35 0 ▶sub handle_upload_form {
Subroutine handle_upload_form: not called CC=2 SCAR=17.9
Pod undocumented
36 0 my $self = shift;
37 0 my $request = shift;
38 0 my $user = $request->user_id;
39 0 my $location = new_location $request->data->{location};
40 0 my $permission = $self->authorisation->permitted( $user, write => $location );
41  
42 0 ▶ if ($permission) {
Branch: 1 branch
BranchTrueFalseTotal
if ($permission) { } 0 0 0
43  
44 0 return new_response 'form/upload', {
45 form => {
46 location => new_location $location, # as string or arrayref?
47 },
48 };
49 }
50 else {
51 0 throw_error Forbidden => $permission->reason;
52 }
53 }
54  
55 0 ▶sub handle_edit_form {
Subroutine handle_edit_form: not called CC=3 SCAR=24.8
Pod undocumented
56 0 my $self = shift;
57 0 my $request = shift;
58  
59 0 my $location = new_location $request->data->{location};
60 0 my $user = $request->user_id;
61 0 my $permission = $self->authorisation->permitted( $user, write => $location );
62  
63 0 ▶ if ($permission) {
Branch: 1 branch
BranchTrueFalseTotal
if ($permission) { } 0 0 0
64  
65 0 ▶ throw_error 'NotFound' unless $self->storage->item_exists($location);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->storage->item_exists($location) 0 0 0
66  
67 0 my $item = $self->storage->get_item($location);
68  
69 # we don't want to interpret at this point
70  
71 0 return new_response 'form/edit', {
72 raw => {
73 meta => $item->meta,
74 content => $item->content,
75 location => $item->location, # as string or arrayref?
76 },
77 };
78 }
79 else {
80 0 throw_error Forbidden => $permission->reason;
81 }
82  
83 }
84  
85 0 ▶sub handle_delete_form {
Subroutine handle_delete_form: not called CC=4 SCAR=30.0
Pod undocumented
86 0 my $self = shift;
87 0 my $request = shift;
88  
89 0 my $item = $request->data;
90 0 my $location = $item->location;
91 0 my $user = $request->user_id;
92 0 my $permission = $self->authorisation->permitted( $user, write => $location );
93  
94 0 ▶ if ( $self->authorisation->permitted( $user, write => $location ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->authorisation->permitted($user, 'write', $location)) { } 0 0 0
95 0 ▶ throw_error 'NotFound' unless $self->storage->item_exists($location);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->storage->item_exists($location) 0 0 0
96  
97 0 my $item = $self->storage->get_item($location);
98 0 my $item_class = $item->location->[-2];
99 0 ▶ $self->augmentation->augment($item) or throw_error 'Internal'; # or throw
Branch: 1 branch
BranchTrueFalseTotal
$self->augmentation->augment($item) or throw_error("Internal") 0 0 0
100  
101 return new_response 'form/delete', {
102 $item_class => {
103 schema => $item->meta->{schema},
104 0 content => $item->content,
105 location => $item->location, # as string or arrayref?
106 },
107 };
108 }
109 else {
110 0 throw_error Forbidden => $permission->reason;
111 }
112  
113 }
114  
115 6 1;
« Articulate/Authentication.pm ↑ Summary Articulate/Authentication/Internal.pm »