DE/URA/Result.pm

filter: Statementstmt 90.9% 60 / 66 Branchbran 71.4% 10 / 14 Conditioncond 52.1% 12 / 23 MC/DCmcdc 14.2% 2 / 14 Subroutinesub 93.7% 15 / 16 Podpod 100% 11 / 11 totaltotal 76.3% 110 / 144 CC 17 SCAR 24.0
CC
17
Cov
80%
route_interesting
22.0
countdown
2.0
countdown_sec
2.0
CRAP 11.0
« DE/URA.pm ↑ Summary DE/ASEAG.pm »
1 package Travel::Status::DE::URA::Result;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use parent 'Class::Accessor';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 ▶use DateTime::Format::Duration;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 our $VERSION = '2.01';
12  
13 5 Travel::Status::DE::URA::Result->mk_ro_accessors(
14 qw(datetime destination line line_id stop stop_id stop_indicator));
15  
16 33161 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
17 33161 my ( $obj, %conf ) = @_;
18  
19 33161 my $ref = \%conf;
20  
21 33161 return bless( $ref, $obj );
22 }
23  
24 2 ▶sub countdown {
Subroutine countdown: called CC=2 SCAR=7.0
Pod documented
25 2 my ($self) = @_;
26  
27 $self->{countdown} //= $self->datetime->subtract_datetime( $self->{dt_now} )
28 2 ▶ ->in_units('minutes');
Condition66%2/3
$self->{"countdown"} //= $self->datetime->subtract_datetime($self->{"dt_now"})->in_units("minutes")
l!l&&r!l&&!r
110
MC/DC0%0/2
$self->{"countdown"} //= $self->datetime->subtract_datetime($self->{"dt_now"})->in_units("minutes")
$self->{"countdown"} $self->datetime->subtract_datetime($self->{"dt_now"})->in_units("minutes")
Truth table66%2/3
A //= B
A= $self->{"countdown"}B= $self->datetime->subtract_datetime($self->{"dt_now"})->in_units("minutes")
ABresult
1X1
011
000
29  
30 2 return $self->{countdown};
31 }
32  
33 2 ▶sub countdown_sec {
Subroutine countdown_sec: called CC=2 SCAR=7.0
Pod documented
34 2 my ($self) = @_;
35 2 my $secpattern = DateTime::Format::Duration->new( pattern => '%s' );
36  
37 $self->{countdown_sec} //= $secpattern->format_duration(
38 2 ▶ $self->datetime->subtract_datetime( $self->{dt_now} ) );
Condition66%2/3
$self->{"countdown_sec"} //= $secpattern->format_duration($self->datetime->subtract_datetime($self->{"dt_now"}))
l!l&&r!l&&!r
110
MC/DC0%0/2
$self->{"countdown_sec"} //= $secpattern->format_duration($self->datetime->subtract_datetime($self->{"dt_now"}))
$self->{"countdown_sec"} $secpattern->format_duration($self->datetime->subtract_datetime($self->{"dt_now"}))
Truth table66%2/3
A //= B
A= $self->{"countdown_sec"}B= $secpattern->format_duration($self->datetime->subtract_datetime($self->{"dt_now"}))
ABresult
1X1
011
000
39  
40 2 return $self->{countdown_sec};
41 }
42  
43 1 ▶sub date {
Subroutine date: called CC=1 SCAR=0.0
Pod documented
44 1 my ($self) = @_;
45  
46 1 return $self->datetime->strftime('%d.%m.%Y');
47 }
48  
49 0 ▶sub platform {
Subroutine platform: not called CC=1 SCAR=6.9
Pod documented
50 0 my ($self) = @_;
51  
52 0 return $self->{stop_indicator};
53 }
54  
55 1 ▶sub time {
Subroutine time: called CC=1 SCAR=0.0
Pod documented
56 1 my ($self) = @_;
57  
58 1 return $self->datetime->strftime('%H:%M:%S');
59 }
60  
61 1 ▶sub type {
Subroutine type: called CC=1 SCAR=0.0
Pod documented
62 1 return 'Bus';
63 }
64  
65 15 ▶sub route_interesting {
Subroutine route_interesting: called CC=15 SCAR=30.9
Pod documented
66 15 my ( $self, $max_parts ) = @_;
67  
68 15 my @via = $self->route_post;
69 15 my ( @via_main, @via_show, $last_stop );
70 15 ▶ $max_parts //= 3;
Condition100%2/2
$max_parts //= 3
l!l
105
MC/DC100%1/1
$max_parts //= 3
$max_parts
Truth table100%2/2
A
A= $max_parts
Aresult
11
00
71  
72 15 for my $stop (@via) {
73 660 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($stop->name =~ / bf | hbf | Flughafen | bahnhof | Krankenhaus | Klinik | bushof | busstation /iox) 30 630 660
74 $stop->name =~ m{ bf | hbf | Flughafen | bahnhof
75 | Krankenhaus | Klinik | bushof | busstation }iox
76 )
77 {
78 30 push( @via_main, $stop );
79 }
80 }
81 15 $last_stop = pop(@via);
82  
83 15 ▶ if ( @via_main and $via_main[-1] == $last_stop ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@via_main and $via_main[-1] == $last_stop) 0 15 15
Condition33%1/3
@via_main and $via_main[-1] == $last_stop
!ll&&!rl&&r
0150
MC/DC0%0/2
@via_main and $via_main[-1] == $last_stop
@via_main $via_main[-1] == $last_stop
Truth table33%1/3
A and B
A= @via_mainB= $via_main[-1] == $last_stop
ABresult
0X0
100
111
84 0 pop(@via_main);
85 }
86 15 ▶ if ( @via and $via[-1] == $last_stop ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@via and $via[-1] == $last_stop) 0 15 15
Condition33%1/3
@via and $via[-1] == $last_stop
!ll&&!rl&&r
0150
MC/DC0%0/2
@via and $via[-1] == $last_stop
@via $via[-1] == $last_stop
Truth table33%1/3
A and B
A= @viaB= $via[-1] == $last_stop
ABresult
0X0
100
111
87 0 pop(@via);
88 }
89  
90 15 ▶ if ( @via_main and @via and $via[0] == $via_main[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@via_main and @via and $via[0] == $via_main[0]) 0 15 15
Condition33%2/6
@via_main and @via and $via[0] == $via_main[0]
!ll&&!rl&&r
0150
@via_main and @via
!ll&&!rl&&r
0015
MC/DC0%0/3
@via_main and @via and $via[0] == $via_main[0]
@via_main @via $via[0] == $via_main[0]
Truth table25%1/4
A and B and C
A= @via_mainB= @viaC= $via[0] == $via_main[0]
ABCresult
0XX0
10X0
1100
1111
91 0 shift(@via_main);
92 }
93  
94 15 ▶ if ( @via < $max_parts ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@via < $max_parts) { } 0 15 15
95 0 @via_show = @via;
96 }
97 else {
98 15 ▶ if ( @via_main >= $max_parts ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@via_main >= $max_parts) { } 5 10 15
99 5 @via_show = ( $via[0] );
100 }
101 else {
102 10 @via_show = splice( @via, 0, $max_parts - @via_main );
103 }
104  
105 15 ▶ while ( @via_show < $max_parts and @via_main ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@via_show < $max_parts and @via_main) 23 15 38
Condition66%2/3
@via_show < $max_parts and @via_main
!ll&&!rl&&r
15023
MC/DC50%1/2
@via_show < $max_parts and @via_main
@via_show < $max_parts @via_main
Truth table66%2/3
A and B
A= @via_show < $max_partsB= @via_main
ABresult
0X0
100
111
106 23 my $stop = shift(@via_main);
107 23 push( @via_show, $stop );
108 }
109 }
110  
111 15 return @via_show;
112 }
113  
114 1 ▶sub route_pre {
Subroutine route_pre: called CC=1 SCAR=0.0
Pod documented
115 1 my ($self) = @_;
116  
117 1 return @{ $self->{route_pre} };
118 }
119  
120 31 ▶sub route_post {
Subroutine route_post: called CC=1 SCAR=0.0
Pod documented
121 31 my ($self) = @_;
122  
123 31 return @{ $self->{route_post} };
124 }
125  
126 8 ▶sub TO_JSON {
Subroutine TO_JSON: called CC=1 SCAR=0.0
Pod documented
127 8 my ($self) = @_;
128  
129 8 return { %{$self} };
130 }
131  
132 5 1;
133  
134 __END__
« DE/URA.pm ↑ Summary DE/ASEAG.pm »