Asterisk/QCall.pm

filter: Statementstmt 52.7% 19 / 36 Branchbran 25.0% 2 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 5 totaltotal 41.9% 26 / 62 CC 6 SCAR 15.5
CC
6
Cov
47%
queuetime
12.0
create_qcall
6.0
new
2.0
CRAP 4.7
« Asterisk/Outgoing.pm ↑ Summary Asterisk.pm »
1 package Asterisk::QCall;
2  
3 1 require 5.004;
4  
5 1 ▶use Fcntl ':flock';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Asterisk;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 $VERSION = '0.01';
9  
10 0 ▶sub version { $VERSION; }
Subroutine version: not called CC=1 SCAR=6.9
Pod undocumented
11  
12 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
13 1 my ($class, %args) = @_;
14 1 my $self = {};
15 1 $self->{QUEUEDIR} = '/var/spool/asterisk/qcall';
16 1 $self->{QUEUETIME} = undef;
17 1 ▶ bless $self, ref $class || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
18 1 return $self;
19 }
20  
21 0 ▶sub DESTROY { }
Subroutine DESTROY: not called CC=1 SCAR=0.0
22  
23 2 ▶sub queuedir {
Subroutine queuedir: called CC=2 SCAR=6.9
Pod undocumented
24 2 my ($self, $dir) = @_;
25  
26 2 ▶ if (defined($dir)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dir) 1 1 2
27 1 $self->{QUEUEDIR} = $dir;
28 }
29  
30 2 return $self->{QUEUEDIR};
31 }
32  
33 0 ▶sub queuetime {
Subroutine queuetime: not called CC=3 SCAR=24.8
Pod undocumented
34 0 my ($self, $time) = @_;
35  
36 0 ▶ if (defined($time)) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $time) { } 0 0 0
elsif (not defined $self->{'QUEUETIME'}) { } 0 0 0
37 0 $self->{QUEUETIME} = $time;
38 } elsif (!defined($self->{QUEUETIME})) {
39 0 $self->{QUEUETIME} = time();
40 }
41  
42 0 return $self->{QUEUETIME};
43 }
44  
45 0 ▶sub create_qcall {
Subroutine create_qcall: not called CC=2 SCAR=17.9
Pod undocumented
46 0 my ($self, $dialstring, $callerid, $extension, $maxsecs, $identifier, $response) = @_;
47  
48 0 my $time = $self->queuetime();
49  
50 0 my $queuedir = $self->queuedir();
51 0 my $filename = $queuedir . '/' . $time . '.queue';
52 0 ▶ open(QFILE, ">$filename") || return 0;
Branch: 1 branch
BranchTrueFalseTotal
open QFILE, ">$filename" or return 0 0 0 0
53 0 flock(QFILE, LOCK_EX);
54 0 print QFILE "$dialstring $callerid $extension $maxsecs $identifier $response";
55 0 flock(QFILE, LOCK_UN);
56 0 close(QFILE);
57 0 my $ret = utime($time, $time, $filename);
58 0 return 1;
59 }
60  
61 1 1;
« Asterisk/Outgoing.pm ↑ Summary Asterisk.pm »