vCloudDirector2/Link.pm

filter: Statementstmt 56.5% 43 / 76 Branchbran 0.0% 0 / 30 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 66.6% 12 / 18 Podpod n/a totaltotal 38.1% 55 / 144 CC 20 SCAR 41.9
CC
20
Cov
36%
__ANON__
182.0
POST
7.9
PUT
7.9
CRAP 66.2
↑ 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.107'; # 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=13 SCAR=52.0
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} ) and defined( $hash->{type} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hash->{"type"} and defined $hash->{"type"}) 0 0 0
Condition0%0/3
exists $hash->{"type"} and defined $hash->{"type"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $hash->{"type"} and defined $hash->{"type"}
exists $hash->{"type"} defined $hash->{"type"}
Truth table0%0/3
A and B
A= exists $hash->{"type"}B= defined $hash->{"type"}
ABresult
0X0
100
111
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 4 ▶method GET_hash () { return $self->object->api->GET_hash( $self->href ); }
Subroutine BEGIN: called CC=1 SCAR=3.1
Subroutine GET_hash: not called CC=2 SCAR=12.4
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 0 0
66  
67  
68 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
69  
70  
71 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
72  
73 # ------------------------------------------------------------------------
74  
75 4 __PACKAGE__->meta->make_immutable;
76  
77 4 1;
78  
79 __END__
80  
81 =pod
82  
83 =encoding UTF-8
84  
85 =head1 NAME
86  
87 VMware::vCloudDirector2::Link - Link within the vCloud
88  
89 =head1 VERSION
90  
91 version 0.107
92  
93 =head3 DELETE
94  
95 Make a delete request to the URL in this link. Returns Objects. Failure will
96 generate an exception. See L<VMware::vCloudDirector2::API/DELETE>.
97  
98 =head3 GET
99  
100 Make a get request to the URL in this link. Returns Objects. Failure will
101 generate an exception. See L<VMware::vCloudDirector2::API/GET>.
102  
103 =head3 GET_hash
104  
105 Make a get request to the URL in this link. Returns a decoded hash. Failure
106 will generate an exception. See L<VMware::vCloudDirector2::API/GET_hash>.
107  
108 =head3 POST
109  
110 Make a post 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/POST>.
113  
114 =head3 PUT
115  
116 Make a put request with the specified payload to the URL in this link. Returns
117 Objects. Failure will generate an exception. See
118 L<VMware::vCloudDirector2::API/PUT>.
119  
120 =head1 AUTHOR
121  
122 Nigel Metheringham <nigelm@cpan.org>
123  
124 =head1 COPYRIGHT AND LICENSE
125  
126 This software is copyright (c) 2019 by Nigel Metheringham.
127  
128 This is free software; you can redistribute it and/or modify it under
129 the same terms as the Perl 5 programming language system itself.
130  
131 =cut
↑ Summary vCloudDirector2/Object.pm »