Metro/Graph/LineStation.pm

filter: Statementstmt 100% 40 / 40 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 3 totaltotal 94.3% 50 / 53 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Metro/Hook.pm ↑ Summary Metro/Elk.pm »
1 14 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Map::Metro::Graph::LineStation;
6  
7 # ABSTRACT: A station on a specific line
8 14 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 14 our $VERSION = '0.2405';
10  
11 14 ▶use Map::Metro::Elk;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 14 ▶use Types::Standard qw/Int/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 14 ▶use Map::Metro::Types qw/Station Line/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 14 ▶use List::Compare;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 14 has line_station_id => (
17 is => 'ro',
18 isa => Int,
19 required => 1,
20 );
21 14 has station => (
22 is => 'ro',
23 isa => Station,
24 required => 1,
25 );
26 14 has line => (
27 is => 'ro',
28 isa => Line,
29 required => 1,
30 );
31  
32 1 ▶sub possible_on_same_line {
Subroutine possible_on_same_line: called CC=1 SCAR=0.0
Pod undocumented
33 1 my $self = shift;
34 1 my $other = shift; # LineStation
35  
36 1 my $station_lines = [ map { $_->id } $self->station->all_lines ];
37 1 my $other_station_lines = [ map { $_->id } $other->station->all_lines ];
38  
39 1 my $is_possible = !!List::Compare->new($station_lines, $other_station_lines)->get_intersection;
40  
41 1 return $is_possible;
42 }
43 1 ▶sub on_same_line {
Subroutine on_same_line: called CC=1 SCAR=0.0
Pod undocumented
44 1 my $self = shift;
45 1 my $other = shift; # LineStation
46  
47 1 return $self->line->id eq $other->line->id;
48 }
49  
50 10 ▶sub to_hash {
Subroutine to_hash: called CC=1 SCAR=0.0
Pod undocumented
51 10 my $self = shift;
52  
53 return {
54 10 line_station_id => $self->line_station_id,
55 station => $self->station->to_hash,
56 line => $self->line->to_hash,
57 };
58 }
59  
60 14 __PACKAGE__->meta->make_immutable;
61  
62 14 1;
63  
64 __END__
« Metro/Hook.pm ↑ Summary Metro/Elk.pm »