vCloudDirector2/Link.pm

filter: Statementstmt 57.7% 41 / 71 Branchbran 0.0% 0 / 28 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 68.7% 11 / 16 Podpod n/a totaltotal 40.0% 52 / 130 CC 18 SCAR 40.8
CC
18
Cov
38%
__ANON__
156.0
POST
7.9
PUT
7.9
CRAP 59.0
↑ Summary vCloudDirector2/Object.pm »
1 package VMware::vCloudDirector2::Link;
2  
3 # ABSTRACT: Link within the vCloud
4  
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 our $VERSION = '0.100'; # VERSION
9 4 our $AUTHORITY = 'cpan:NIGELM'; # AUTHORITY
10  
11 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Method::Signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use MooseX::Types::URI qw(Uri);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use Ref::Util qw(is_plain_hashref);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use VMware::vCloudDirector2::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 # ------------------------------------------------------------------------
18  
19 4 has object => (
20 is => 'ro',
21 isa => 'VMware::vCloudDirector2::Object',
22 required => 1,
23 weak_ref => 1,
24 documentation => 'Parent object of link'
25 );
26  
27 4 has mime_type => ( is => 'ro', isa => 'Str', predicate => 'has_mime_type' );
28 4 has href => ( is => 'ro', isa => Uri, required => 1, coerce => 1 );
29 4 has rel => ( is => 'ro', isa => 'Str', required => 1 );
30 4 has name => ( is => 'ro', isa => 'Str', predicate => 'has_name' );
31 4 has type => ( is => 'ro', isa => 'Str' );
32 4 has is_json => ( is => 'ro', isa => 'Bool' );
33  
34 # ------------------------------------------------------------------------
35 around BUILDARGS => sub {
36 0 ▶ my ( $orig, $class, $first, @rest ) = @_;
Subroutine __ANON__: not called CC=12 SCAR=50.5
37  
38 0 ▶ my $params = is_plain_hashref($first) ? $first : { $first, @rest };
Branch: 1 branch
BranchTrueFalseTotal
is_plain_hashref($first) ? : 0 0 0
39  
40 0 ▶ if ( $params->{hash} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"hash"}) 0 0 0
41 0 my $hash = delete $params->{hash};
42 0 ▶ $params->{href} = $hash->{href} if ( exists( $hash->{href} ) and defined( $hash->{href} ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $hash->{"href"} and defined $hash->{"href"} 0 0 0
Condition0%0/3
exists $hash->{"href"} and defined $hash->{"href"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $hash->{"href"} and defined $hash->{"href"}
exists $hash->{"href"} defined $hash->{"href"}
Truth table0%0/3
A and B
A= exists $hash->{"href"}B= defined $hash->{"href"}
ABresult
0X0
100
111
43 0 ▶ $params->{rel} = $hash->{rel} if ( exists( $hash->{rel} ) and defined( $hash->{rel} ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $hash->{"rel"} and defined $hash->{"rel"} 0 0 0
Condition0%0/3
exists $hash->{"rel"} and defined $hash->{"rel"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $hash->{"rel"} and defined $hash->{"rel"}
exists $hash->{"rel"} defined $hash->{"rel"}
Truth table0%0/3
A and B
A= exists $hash->{"rel"}B= defined $hash->{"rel"}
ABresult
0X0
100
111
44 0 ▶ $params->{name} = $hash->{name} if ( exists( $hash->{name} ) and defined( $hash->{name} ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $hash->{"name"} and defined $hash->{"name"} 0 0 0
Condition0%0/3
exists $hash->{"name"} and defined $hash->{"name"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $hash->{"name"} and defined $hash->{"name"}
exists $hash->{"name"} defined $hash->{"name"}
Truth table0%0/3
A and B
A= exists $hash->{"name"}B= defined $hash->{"name"}
ABresult
0X0
100
111
45 0 ▶ if ( exists( $hash->{type} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hash->{"type"}) 0 0 0
46 0 my $type = $hash->{type};
47 0 $params->{mime_type} = $type;
48 0 ▶ if ( $type =~ m!^application/vnd\..*\.(\w+)\+(json|xml)$! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ m[^application/vnd\..*\.(\w+)\+(json|xml)$]) 0 0 0
49 0 $params->{type} = $1;
50 0 ▶ $params->{is_json} = ( $2 eq 'json' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$2 eq 'json' ? : 0 0 0
51 }
52 }
53 }
54  
55 0 return $class->$orig($params);
56 4 };
57  
58 # ------------------------------------------------------------------------
59  
60  
61 4 ▶method DELETE () { return $self->object->api->DELETE( $self->href ); }
Subroutine BEGIN: called CC=1 SCAR=3.1
Subroutine DELETE: not called CC=2 SCAR=12.4
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 0 0
62  
63  
64 4 ▶method GET () { return $self->object->api->GET( $self->href ); }
Subroutine BEGIN: called CC=1 SCAR=3.1
Subroutine GET: not called CC=2 SCAR=12.4
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 0 0
65  
66  
67 4 ▶method POST ($hash) { return $self->object->api->POST( $self->href, $hash, $self->mime_type ); }
Subroutine BEGIN: called CC=1 SCAR=4.4
Subroutine POST: not called CC=3 SCAR=20.7
Branch: 2 branches
BranchTrueFalseTotal
unless scalar @_ > 0 0 0 0
if scalar @_ > 1 0 0 0
68  
69  
70 4 ▶method PUT ($hash) { return $self->object->api->PUT( $self->href, $hash, $self->mime_type ); }
Subroutine BEGIN: called CC=1 SCAR=4.4
Subroutine PUT: not called CC=3 SCAR=20.7
Branch: 2 branches
BranchTrueFalseTotal
unless scalar @_ > 0 0 0 0
if scalar @_ > 1 0 0 0
71  
72 # ------------------------------------------------------------------------
73  
74 4 __PACKAGE__->meta->make_immutable;
75  
76 4 1;
77  
78 __END__
79  
80 =pod
81  
82 =encoding UTF-8
83  
84 =head1 NAME
85  
86 VMware::vCloudDirector2::Link - Link within the vCloud
87  
88 =head1 VERSION
89  
90 version 0.100
91  
92 =head3 DELETE
93  
94 Make a delete request to the URL in this link. Returns Objects. Failure will
95 generate an exception. See L<VMware::vCloudDirector2::API/DELETE>.
96  
97 =head3 GET
98  
99 Make a get request to the URL in this link. Returns Objects. Failure will
100 generate an exception. See L<VMware::vCloudDirector2::API/GET>.
101  
102 =head3 POST
103  
104 Make a post request with the specified payload to the URL in this link. Returns
105 Objects. Failure will generate an exception. See
106 L<VMware::vCloudDirector2::API/POST>.
107  
108 =head3 PUT
109  
110 Make a put request with the specified payload to the URL in this link. Returns
111 Objects. Failure will generate an exception. See
112 L<VMware::vCloudDirector2::API/PUT>.
113  
114 =head1 AUTHOR
115  
116 Nigel Metheringham <nigelm@cpan.org>
117  
118 =head1 COPYRIGHT AND LICENSE
119  
120 This software is copyright (c) 2019 by Nigel Metheringham.
121  
122 This is free software; you can redistribute it and/or modify it under
123 the same terms as the Perl 5 programming language system itself.
124  
125 =cut
↑ Summary vCloudDirector2/Object.pm »