Metro/Graph/Line.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 93.4% 43 / 46 CC 2 SCAR 2.1
CC
2
Cov
95%
__ANON__
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Metro/Graph/Segment.pm ↑ Summary Metro/Cmd/Available.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::Line;
6  
7 # ABSTRACT: Meta information about a line
8 14 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 14 our $VERSION = '0.2404';
10  
11 14 ▶use Map::Metro::Elk;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 14 ▶use Types::Standard qw/Str Int/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 14 ▶use Map::Metro::Exceptions;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 14 has id => (
16 is => 'ro',
17 isa => Str,
18 required => 1,
19 );
20 14 has name => (
21 is => 'ro',
22 isa => Str,
23 required => 1,
24 );
25 14 has description => (
26 is => 'ro',
27 isa => Str,
28 required => 1,
29 );
30 14 has color => (
31 is => 'rw',
32 isa => Str,
33 default => '#333333',
34 );
35 14 has width => (
36 is => 'rw',
37 isa => Int,
38 default => 3,
39 );
40  
41 around BUILDARGS => sub {
42 8 ▶ my $orig = shift;
Subroutine __ANON__: called CC=2 SCAR=7.2
43 8 my $self = shift;
44 8 my %args = @_;
45  
46 8 ▶ if($args{'id'} =~ m{([^a-z0-9])}i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"id"} =~ /([^a-z0-9])/i) 0 8 8
47 0 die lineid_contains_illegal_character line_id => $args{'id'}, illegal_character => $_;
48 }
49 8 $self->$orig(%args);
50 14 };
51  
52 sub to_hash {
53 22 ▶ my $self = shift;
Subroutine to_hash: called CC=1 SCAR=0.0
Pod undocumented
54  
55 return {
56 22 id => $self->id,
57 name => $self->name,
58 description => $self->description,
59 color => $self->color,
60 width => $self->width,
61 }
62 }
63  
64 14 __PACKAGE__->meta->make_immutable;
65  
66 14 1;
67  
68 __END__
69  
70 =pod
71  
72 =encoding UTF-8
73  
74 =head1 NAME
75  
76 Map::Metro::Graph::Line - Meta information about a line
77  
78 =head1 VERSION
79  
80 Version 0.2404, released 2016-04-30.
81  
82 =head1 DESCRIPTION
83  
84 Lines are currently only placeholders to identify the concept of a line. They don't have stations.
85  
86 =head1 METHODS
87  
88 =head2 id()
89  
90 Returns the line id given in the parsed map file.
91  
92 =head2 name()
93  
94 Returns the line name given in the parsed map file.
95  
96 =head2 description()
97  
98 Returns the line description given in the parsed map file.
99  
100 =head1 SOURCE
101  
102 L<https://github.com/Csson/p5-Map-Metro>
103  
104 =head1 HOMEPAGE
105  
106 L<https://metacpan.org/release/Map-Metro>
107  
108 =head1 AUTHOR
109  
110 Erik Carlsson <info@code301.com>
111  
112 =head1 COPYRIGHT AND LICENSE
113  
114 This software is copyright (c) 2016 by Erik Carlsson.
115  
116 This is free software; you can redistribute it and/or modify it under
117 the same terms as the Perl 5 programming language system itself.
118  
119 =cut
« Metro/Graph/Segment.pm ↑ Summary Metro/Cmd/Available.pm »