Object/Line.pm untested

filter: Statementstmt 0.0% 0 / 93 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 18 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 126 CC 6 SCAR 16.0
CC
6
Cov
0%
from_hash
12.0
_deserialize
12.0
TO_JSON
6.0
CRAP 5.0
1 =begin comment
2
3 Copyright (c) 2026 Aspose.Cells Cloud
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21
22 =end comment
23
24 =cut
25
26 package AsposeCellsCloud::Object::Line;
27
28 require 5.6.0;
29 use strict;
30 use warnings;
31 use utf8;
32 use JSON qw(decode_json);
33 use Data::Dumper;
34 use Module::Runtime qw(use_module);
35 use Log::Any qw($log);
36 use Date::Parse;
37 use DateTime;
38 use AsposeCellsCloud::Object::Color;
39 use AsposeCellsCloud::Object::GradientFill;
40
41
42 use base ("Class::Accessor", "Class::Data::Inheritable");
43
44
45
46 __PACKAGE__->mk_classdata('attribute_map' => {});
47 __PACKAGE__->mk_classdata('swagger_types' => {});
48 __PACKAGE__->mk_classdata('method_documentation' => {});
49 __PACKAGE__->mk_classdata('class_documentation' => {});
50
51 # new object
52 sub new {
53 my ($class, %args) = @_;
54
55 my $self = bless {}, $class;
56
57 foreach my $attribute (keys %{$class->attribute_map}) {
58 my $args_key = $class->attribute_map->{$attribute};
59 $self->$attribute( $args{ $args_key } );
60 }
61
62 return $self;
63 }
64
65 # return perl hash
66 sub to_hash {
67 return decode_json(JSON->new->convert_blessed->encode( shift ));
68 }
69
70 # used by JSON for serialization
71 sub TO_JSON {
72 my $self = shift;
73 my $_data = {};
74 foreach my $_key (keys %{$self->attribute_map}) {
75 if (defined $self->{$_key}) {
76 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
77 }
78 }
79 return $_data;
80 }
81
82 # from Perl hashref
83 sub from_hash {
84 my ($self, $hash) = @_;
85
86 # loop through attributes and use swagger_types to deserialize the data
87 while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
88 my $_json_attribute = $self->attribute_map->{$_key};
89 if ($_type =~ /^array\[/i) { # array
90 my $_subclass = substr($_type, 6, -1);
91 my @_array = ();
92 foreach my $_element (@{$hash->{$_json_attribute}}) {
93 push @_array, $self->_deserialize($_subclass, $_element);
94 }
95 $self->{$_key} = \@_array;
96 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
97 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
98 } else {
99 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
100 }
101 }
102
103 return $self;
104 }
105
106 # deserialize non-array data
107 sub _deserialize {
108 my ($self, $type, $data) = @_;
109 $log->debugf("deserializing %s with %s",Dumper($data), $type);
110
111 if ($type eq 'DateTime') {
112 return DateTime->from_epoch(epoch => str2time($data));
113 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
114 return $data;
115 } else { # hash(model)
116 my $_instance = eval "AsposeCellsCloud::Object::$type->new()";
117 return $_instance->from_hash($data);
118 }
119 }
120
121
122 __PACKAGE__->class_documentation({description => 'Encapsulates the object that represents the line format.',
123 class => 'Line',
124 required => [], # TODO
125 } );
126
127
128 __PACKAGE__->method_documentation({
129 'begin_arrow_length' => {
130 datatype => 'string',
131 base_name => 'BeginArrowLength',
132 description => 'Specifies the length of the arrowhead for the begin of a line. ',
133 format => '',
134 read_only => '',
135 },
136 'begin_arrow_width' => {
137 datatype => 'string',
138 base_name => 'BeginArrowWidth',
139 description => 'Specifies the width of the arrowhead for the begin of a line. ',
140 format => '',
141 read_only => '',
142 },
143 'begin_type' => {
144 datatype => 'string',
145 base_name => 'BeginType',
146 description => 'Specifies an arrowhead for the begin of a line. ',
147 format => '',
148 read_only => '',
149 },
150 'cap_type' => {
151 datatype => 'string',
152 base_name => 'CapType',
153 description => 'Specifies the ending caps. ',
154 format => '',
155 read_only => '',
156 },
157 'color' => {
158 datatype => 'Color',
159 base_name => 'Color',
160 description => 'Represents the of the line. ',
161 format => '',
162 read_only => '',
163 },
164 'compound_type' => {
165 datatype => 'string',
166 base_name => 'CompoundType',
167 description => 'Specifies the compound line type ',
168 format => '',
169 read_only => '',
170 },
171 'dash_type' => {
172 datatype => 'string',
173 base_name => 'DashType',
174 description => 'Specifies the dash line type ',
175 format => '',
176 read_only => '',
177 },
178 'end_arrow_length' => {
179 datatype => 'string',
180 base_name => 'EndArrowLength',
181 description => 'Specifies the length of the arrowhead for the end of a line. ',
182 format => '',
183 read_only => '',
184 },
185 'end_arrow_width' => {
186 datatype => 'string',
187 base_name => 'EndArrowWidth',
188 description => 'Specifies the width of the arrowhead for the end of a line. ',
189 format => '',
190 read_only => '',
191 },
192 'end_type' => {
193 datatype => 'string',
194 base_name => 'EndType',
195 description => 'Specifies an arrowhead for the end of a line. ',
196 format => '',
197 read_only => '',
198 },
199 'gradient_fill' => {
200 datatype => 'GradientFill',
201 base_name => 'GradientFill',
202 description => 'Represents gradient fill. ',
203 format => '',
204 read_only => '',
205 },
206 'is_auto' => {
207 datatype => 'boolean',
208 base_name => 'IsAuto',
209 description => 'Indicates whether this line style is auto assigned. ',
210 format => '',
211 read_only => '',
212 },
213 'is_automatic_color' => {
214 datatype => 'boolean',
215 base_name => 'IsAutomaticColor',
216 description => 'Indicates whether the color of line is automatic assigned. ',
217 format => '',
218 read_only => '',
219 },
220 'is_visible' => {
221 datatype => 'boolean',
222 base_name => 'IsVisible',
223 description => 'Represents whether the line is visible. ',
224 format => '',
225 read_only => '',
226 },
227 'join_type' => {
228 datatype => 'string',
229 base_name => 'JoinType',
230 description => 'Specifies the joining caps. ',
231 format => '',
232 read_only => '',
233 },
234 'style' => {
235 datatype => 'string',
236 base_name => 'Style',
237 description => 'Represents the style of the line. ',
238 format => '',
239 read_only => '',
240 },
241 'transparency' => {
242 datatype => 'double',
243 base_name => 'Transparency',
244 description => 'Returns or sets the degree of transparency of the line as a value from 0.0 (opaque) through 1.0 (clear). ',
245 format => '',
246 read_only => '',
247 },
248 'weight' => {
249 datatype => 'string',
250 base_name => 'Weight',
251 description => 'Gets or sets the of the line. ',
252 format => '',
253 read_only => '',
254 },
255 'weight_pt' => {
256 datatype => 'double',
257 base_name => 'WeightPt',
258 description => 'Gets or sets the weight of the line in unit of points. ',
259 format => '',
260 read_only => '',
261 },
262 });
263
264 __PACKAGE__->swagger_types( {
265 'begin_arrow_length' => 'string',
266 'begin_arrow_width' => 'string',
267 'begin_type' => 'string',
268 'cap_type' => 'string',
269 'color' => 'Color',
270 'compound_type' => 'string',
271 'dash_type' => 'string',
272 'end_arrow_length' => 'string',
273 'end_arrow_width' => 'string',
274 'end_type' => 'string',
275 'gradient_fill' => 'GradientFill',
276 'is_auto' => 'boolean',
277 'is_automatic_color' => 'boolean',
278 'is_visible' => 'boolean',
279 'join_type' => 'string',
280 'style' => 'string',
281 'transparency' => 'double',
282 'weight' => 'string',
283 'weight_pt' => 'double'
284 } );
285
286 __PACKAGE__->attribute_map( {
287 'begin_arrow_length' => 'BeginArrowLength',
288 'begin_arrow_width' => 'BeginArrowWidth',
289 'begin_type' => 'BeginType',
290 'cap_type' => 'CapType',
291 'color' => 'Color',
292 'compound_type' => 'CompoundType',
293 'dash_type' => 'DashType',
294 'end_arrow_length' => 'EndArrowLength',
295 'end_arrow_width' => 'EndArrowWidth',
296 'end_type' => 'EndType',
297 'gradient_fill' => 'GradientFill',
298 'is_auto' => 'IsAuto',
299 'is_automatic_color' => 'IsAutomaticColor',
300 'is_visible' => 'IsVisible',
301 'join_type' => 'JoinType',
302 'style' => 'Style',
303 'transparency' => 'Transparency',
304 'weight' => 'Weight',
305 'weight_pt' => 'WeightPt'
306 } );
307
308 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
309
310
311 1;