RestApi/SheetsApi4/Range/Cell.pm

filter: Statementstmt 89.3% 42 / 47 Branchbran 83.3% 10 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 84.6% 11 / 13 Podpod 80.0% 4 / 5 totaltotal 82.9% 68 / 82 CC 8 SCAR 7.8
CC
8
Cov
85%
new
4.1
values
3.0
batch_values
2.0
CRAP 2.2
« RestApi/SubResource.pm ↑ Summary RestApi/CalendarApi3/Calendar.pm »
1 package Google::RestApi::SheetsApi4::Range::Cell;
2  
3 2 our $VERSION = '2.2.5';
4  
5 2 ▶use Google::RestApi::Setup;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Try::Tiny qw( try catch );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use aliased 'Google::RestApi::SheetsApi4::Range';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use parent Range;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # make sure the translated range refers to a single cell (no ':').
14 137 ▶sub new {
Subroutine new: called CC=4 SCAR=14.2
Pod documented
15 137 my $class = shift;
16 137 my %self = @_;
17  
18 # this is fucked up, but want to support creating this object directly and also
19 # via the range::factory method, so have to handle both cases here. try to create
20 # the cell directly first (which could also come via the factory method, which will
21 # have already translated the address into a cell), and failing that, see if the
22 # range factory can create a cell (which will resolve any named or header references).
23 # this has the potential of looping between this and factory method.
24  
25 # if factory has already been used, then this should resolve here.
26 137 my $err;
27 137 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
28 137 state $check = signature(positional => [RangeCell]);
29 137 ($self{range}) = $check->($self{range});
30 2 ▶ } catch {
Subroutine __ANON__: called CC=1 SCAR=0.0
31 2 $err = $_;
32 137 };
33 137 ▶ return $class->SUPER::new(%self) if !$err;
Branch: 1 branch
BranchTrueFalseTotal
unless $err 135 2 137
34  
35 # see if the range passed can be translated to what we want via the factory.
36 2 my $factory_range;
37 2 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
38 2 $factory_range = Google::RestApi::SheetsApi4::Range::factory(%self);
39 2 ▶ } catch {};
Subroutine __ANON__: not called CC=1 SCAR=0.0
40 2 ▶ return $factory_range if $factory_range && $factory_range->isa(__PACKAGE__);
Branch: 1 branch
BranchTrueFalseTotal
if $factory_range and $factory_range->isa(__PACKAGE__) 2 0 2
Condition33%1/3
$factory_range and $factory_range->isa(__PACKAGE__)
!ll&&!rl&&r
002
MC/DC0%0/2
$factory_range and $factory_range->isa(__PACKAGE__)
$factory_range $factory_range->isa(__PACKAGE__)
Truth table33%1/3
A and B
A= $factory_rangeB= $factory_range->isa(__PACKAGE__)
ABresult
0X0
100
111
41  
42 0 LOGDIE sprintf("Unable to translate '%s' into a worksheet cell: $err", flatten_range($self{range}));
43 }
44  
45 101 ▶sub values {
Subroutine values: called CC=3 SCAR=11.0
Pod documented
46 101 my $self = shift;
47 101 state $check = signature(
48 bless => !!0,
49 named => [
50 values => Str, { optional => 1 },
51 _extra_ => slurpy HashRef,
52 ],
53 );
54 101 my $p = named_extra($check->(@_));
55 101 ▶ $p->{values} = [[ $p->{values} ]] if defined $p->{values};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"values"} 0 101 101
56 101 my $values = $self->SUPER::values(%$p);
57 101 ▶ return defined $values ? $values->[0]->[0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $values ? : 90 11 101
58 }
59  
60 36 ▶sub batch_values {
Subroutine batch_values: called CC=2 SCAR=6.9
Pod documented
61 36 my $self = shift;
62  
63 36 state $check = signature(
64 bless => !!0,
65 named => [
66 values => Str, { optional => 1 },
67 ],
68 );
69 36 my $p = $check->(@_);
70  
71 36 ▶ $p->{values} = [[ $p->{values} ]] if $p->{values};
Branch: 1 branch
BranchTrueFalseTotal
if $$p{"values"} 18 18 36
72 36 return $self->SUPER::batch_values(%$p);
73 }
74  
75 # is this 0 or infinity? return self if offset is 0, undef otherwise.
76 4 ▶sub cell_at_offset {
Subroutine cell_at_offset: called CC=2 SCAR=6.9
Pod undocumented
77 4 my $self = shift;
78 4 state $check = signature(positional => [Int, DimColRow, { optional => 1 }]);
79 4 my ($offset) = $check->(@_); # we're a cell, no dim required.
80 4 ▶ return $self if !$offset;
Branch: 1 branch
BranchTrueFalseTotal
unless $offset 2 2 4
81 2 return;
82 }
83  
84 0 ▶sub is_other_inside {
Subroutine is_other_inside: not called CC=1 SCAR=6.9
Pod documented
85 0 my $self = shift;
86 0 state $check = signature(positional => [HasRange]);
87 0 my ($inside_range) = $check->(@_);
88 0 return $self->range() eq $inside_range->range();
89 }
90  
91 2 1;
92  
93 __END__
« RestApi/SubResource.pm ↑ Summary RestApi/CalendarApi3/Calendar.pm »