Connection/LogMethodCall.pm

filter: Statementstmt 91.8% 34 / 37 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 88.8% 48 / 54 SCAR 19.5
CC
7
Cov
89%
dump_method_call
7.2
BEGIN
1.0
BEGIN
1.0
CRAP 7.1
« MultiChannelInstrument/DeviceCache.pm ↑ Summary Connection/Log.pm »
1 package Lab::Connection::LogMethodCall;
2 #ABSTRACT: ???
3 6 $Lab::Connection::LogMethodCall::VERSION = '3.881';
4 6 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 6 our @EXPORT = qw(dump_method_call);
13  
14 # Return a hashref, which describes the method call. Does not include the
15 # methods's return value.
16 sub dump_method_call {
17 664 ▶ my $id = shift;
Subroutine dump_method_call: called CC=7 SCAR=19.8
Pod undocumented
18 664 my $method = shift;
19 664 my @args = @_;
20  
21 664 my $log = {
22 id => $id,
23 method => $method,
24 };
25  
26 664 ▶ if ( $method =~ /Clear|block_connection|unblock_connection|is_blocked/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method =~ /Clear|block_connection|unblock_connection|is_blocked/u) 316 348 664
27  
28 # These method take no arguments.
29 316 return $log;
30 }
31  
32 348 ▶ if ( $method eq 'timeout' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method eq "timeout") 0 348 348
33  
34 # timeout takes a single argument.
35 0 $log->{timeout} = $args[0];
36 0 return $log;
37 }
38  
39 # The remaining methods get either a flat hash or a hashref.
40  
41 348 my $config;
42  
43 348 ▶ if ( ref $args[0] eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args[0] eq 'HASH') { } 253 95 348
44 253 $config = $args[0];
45 }
46 else {
47 95 $config = {@args};
48 }
49  
50 348 for my $param (qw/command read_length brutal wait_query/) {
51 1392 ▶ if ( defined $config->{$param} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $config->{$param}) 348 1044 1392
52 348 my $key = $config->{$param};
53 348 ▶ if ( ref $key ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $key) 0 348 348
54  
55 # Should never happen.
56 0 croak "$param is a ref";
57 }
58 348 $log->{$param} = $key;
59 }
60 }
61  
62 348 return $log;
63 }
64  
65 6 1;
66  
67 __END__
68  
69 =pod
70  
71 =encoding UTF-8
72  
73 =head1 NAME
74  
75 Lab::Connection::LogMethodCall - ???
76  
77 =head1 VERSION
78  
79 version 3.881
80  
81 =head1 COPYRIGHT AND LICENSE
82  
83 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
84  
85 Copyright 2016 Simon Reinhardt
86 2017 Andreas K. Huettel
87 2020 Andreas K. Huettel
88  
89  
90 This is free software; you can redistribute it and/or modify it under
91 the same terms as the Perl 5 programming language system itself.
92  
93 =cut
« MultiChannelInstrument/DeviceCache.pm ↑ Summary Connection/Log.pm »