Object/TextOptions.pm untested

filter: Statementstmt 0.0% 0 / 105 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 22 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 142 CC 6 SCAR 15.1
CC
6
Cov
0%
from_hash
12.0
_deserialize
12.0
TO_JSON
6.0
CRAP 4.5
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::TextOptions;
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::CellsColor;
39 use AsposeCellsCloud::Object::Color;
40 use AsposeCellsCloud::Object::FillFormat;
41 use AsposeCellsCloud::Object::Font;
42 use AsposeCellsCloud::Object::LineFormat;
43 use AsposeCellsCloud::Object::ShadowEffect;
44
45
46 use base ("Class::Accessor", "Class::Data::Inheritable");
47
48
49
50 __PACKAGE__->mk_classdata('attribute_map' => {});
51 __PACKAGE__->mk_classdata('swagger_types' => {});
52 __PACKAGE__->mk_classdata('method_documentation' => {});
53 __PACKAGE__->mk_classdata('class_documentation' => {});
54
55 # new object
56 sub new {
57 my ($class, %args) = @_;
58
59 my $self = bless {}, $class;
60
61 foreach my $attribute (keys %{$class->attribute_map}) {
62 my $args_key = $class->attribute_map->{$attribute};
63 $self->$attribute( $args{ $args_key } );
64 }
65
66 return $self;
67 }
68
69 # return perl hash
70 sub to_hash {
71 return decode_json(JSON->new->convert_blessed->encode( shift ));
72 }
73
74 # used by JSON for serialization
75 sub TO_JSON {
76 my $self = shift;
77 my $_data = {};
78 foreach my $_key (keys %{$self->attribute_map}) {
79 if (defined $self->{$_key}) {
80 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
81 }
82 }
83 return $_data;
84 }
85
86 # from Perl hashref
87 sub from_hash {
88 my ($self, $hash) = @_;
89
90 # loop through attributes and use swagger_types to deserialize the data
91 while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
92 my $_json_attribute = $self->attribute_map->{$_key};
93 if ($_type =~ /^array\[/i) { # array
94 my $_subclass = substr($_type, 6, -1);
95 my @_array = ();
96 foreach my $_element (@{$hash->{$_json_attribute}}) {
97 push @_array, $self->_deserialize($_subclass, $_element);
98 }
99 $self->{$_key} = \@_array;
100 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
101 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
102 } else {
103 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
104 }
105 }
106
107 return $self;
108 }
109
110 # deserialize non-array data
111 sub _deserialize {
112 my ($self, $type, $data) = @_;
113 $log->debugf("deserializing %s with %s",Dumper($data), $type);
114
115 if ($type eq 'DateTime') {
116 return DateTime->from_epoch(epoch => str2time($data));
117 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
118 return $data;
119 } else { # hash(model)
120 my $_instance = eval "AsposeCellsCloud::Object::$type->new()";
121 return $_instance->from_hash($data);
122 }
123 }
124
125
126 __PACKAGE__->class_documentation({description => 'Represents the text options.',
127 class => 'TextOptions',
128 required => [], # TODO
129 } );
130
131
132 __PACKAGE__->method_documentation({
133 'fill' => {
134 datatype => 'FillFormat',
135 base_name => 'Fill',
136 description => 'Represents fill format.',
137 format => '',
138 read_only => '',
139 },
140 'kerning' => {
141 datatype => 'double',
142 base_name => 'Kerning',
143 description => 'Represents kerning.',
144 format => '',
145 read_only => '',
146 },
147 'outline' => {
148 datatype => 'LineFormat',
149 base_name => 'Outline',
150 description => 'Represents outline format.',
151 format => '',
152 read_only => '',
153 },
154 'shadow' => {
155 datatype => 'ShadowEffect',
156 base_name => 'Shadow',
157 description => 'Represents shadow effect.',
158 format => '',
159 read_only => '',
160 },
161 'spacing' => {
162 datatype => 'double',
163 base_name => 'Spacing',
164 description => 'Represents spacing.',
165 format => '',
166 read_only => '',
167 },
168 'underline_color' => {
169 datatype => 'CellsColor',
170 base_name => 'UnderlineColor',
171 description => 'Represents under line color.',
172 format => '',
173 read_only => '',
174 },
175 'color' => {
176 datatype => 'Color',
177 base_name => 'Color',
178 description => '',
179 format => '',
180 read_only => '',
181 },
182 'double_size' => {
183 datatype => 'double',
184 base_name => 'DoubleSize',
185 description => '',
186 format => '',
187 read_only => '',
188 },
189 'is_bold' => {
190 datatype => 'boolean',
191 base_name => 'IsBold',
192 description => '',
193 format => '',
194 read_only => '',
195 },
196 'is_italic' => {
197 datatype => 'boolean',
198 base_name => 'IsItalic',
199 description => '',
200 format => '',
201 read_only => '',
202 },
203 'is_strikeout' => {
204 datatype => 'boolean',
205 base_name => 'IsStrikeout',
206 description => '',
207 format => '',
208 read_only => '',
209 },
210 'is_subscript' => {
211 datatype => 'boolean',
212 base_name => 'IsSubscript',
213 description => '',
214 format => '',
215 read_only => '',
216 },
217 'is_superscript' => {
218 datatype => 'boolean',
219 base_name => 'IsSuperscript',
220 description => '',
221 format => '',
222 read_only => '',
223 },
224 'name' => {
225 datatype => 'string',
226 base_name => 'Name',
227 description => 'The class has a public property named "Name" with a getter and setter method.',
228 format => '',
229 read_only => '',
230 },
231 'size' => {
232 datatype => 'int',
233 base_name => 'Size',
234 description => '',
235 format => '',
236 read_only => '',
237 },
238 'underline' => {
239 datatype => 'string',
240 base_name => 'Underline',
241 description => '',
242 format => '',
243 read_only => '',
244 },
245 });
246
247 __PACKAGE__->swagger_types( {
248 'fill' => 'FillFormat',
249 'kerning' => 'double',
250 'outline' => 'LineFormat',
251 'shadow' => 'ShadowEffect',
252 'spacing' => 'double',
253 'underline_color' => 'CellsColor',
254 'color' => 'Color',
255 'double_size' => 'double',
256 'is_bold' => 'boolean',
257 'is_italic' => 'boolean',
258 'is_strikeout' => 'boolean',
259 'is_subscript' => 'boolean',
260 'is_superscript' => 'boolean',
261 'name' => 'string',
262 'size' => 'int',
263 'underline' => 'string'
264 } );
265
266 __PACKAGE__->attribute_map( {
267 'fill' => 'Fill',
268 'kerning' => 'Kerning',
269 'outline' => 'Outline',
270 'shadow' => 'Shadow',
271 'spacing' => 'Spacing',
272 'underline_color' => 'UnderlineColor',
273 'color' => 'Color',
274 'double_size' => 'DoubleSize',
275 'is_bold' => 'IsBold',
276 'is_italic' => 'IsItalic',
277 'is_strikeout' => 'IsStrikeout',
278 'is_subscript' => 'IsSubscript',
279 'is_superscript' => 'IsSuperscript',
280 'name' => 'Name',
281 'size' => 'Size',
282 'underline' => 'Underline'
283 } );
284
285 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
286
287
288 1;