Etch/Material.pm

filter: Statementstmt 92.0% 23 / 25 Branchbran 83.3% 5 / 6 Conditioncond 80.0% 4 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 80.0% 8 / 10 Podpod 0.0% 0 / 7 totaltotal 73.2% 41 / 56 CC 6 SCAR 7.9
CC
6
Cov
89%
new
4.0
label
2.1
name
2.0
CRAP 2.2
« Etch/WetEtch.pm ↑ Summary
1 package Physics::Etch::Material;
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  
6 5 our $VERSION = '0.02';
7  
8 # A thin film / bulk material that can be etched or used as mask/substrate.
9 #
10 # name short key, e.g. 'copper'
11 # formula chemical formula, e.g. 'Cu'
12 # pretty display name, e.g. 'Copper'
13 # density g/cm^3 (optional, informational)
14 # thickness nm (optional; the film thickness to be removed)
15  
16 34 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod undocumented
17 34 my ( $class, %args ) = @_;
18  
19 my $name = $args{name}
20 34 ▶ or die "Physics::Etch::Material: 'name' is required\n";
Branch: 1 branch
BranchTrueFalseTotal
my $name = $args{"name"} or die "Physics::Etch::Material: 'name' is required\n" 33 1 34
21  
22 my $self = {
23 name => $name,
24 formula => $args{formula} // '',
25 pretty => $args{pretty} // _titlecase($name),
26 density => $args{density}, # g/cm^3
27 thickness => $args{thickness}, # nm
28 33 ▶ };
Condition80%4/5
$args{"formula"} // ""
l!l
2112
$args{"pretty"} // _titlecase($name)
l!l&&r!l&&!r
21120
MC/DC100%1/1
$args{"formula"} // ""
$args{"formula"}
MC/DC0%0/2
$args{"pretty"} // _titlecase($name)
$args{"pretty"} _titlecase($name)
Truth table100%2/2
A
A= $args{"formula"}
Aresult
11
00
Truth table66%2/3
A // B
A= $args{"pretty"}B= _titlecase($name)
ABresult
1X1
011
000
29  
30 33 return bless $self, $class;
31 }
32  
33 0 ▶sub name { $_[0]->{name} }
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
34 1 ▶sub formula { $_[0]->{formula} }
Subroutine formula: called CC=1 SCAR=0.0
Pod undocumented
35 6 ▶sub pretty { $_[0]->{pretty} }
Subroutine pretty: called CC=1 SCAR=0.0
Pod undocumented
36 0 ▶sub density { $_[0]->{density} }
Subroutine density: not called CC=1 SCAR=6.9
Pod undocumented
37  
38 47 ▶sub thickness {
Subroutine thickness: called CC=2 SCAR=6.9
Pod undocumented
39 47 my ( $self, $value ) = @_;
40 47 ▶ $self->{thickness} = $value if defined $value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 11 36 47
41 47 return $self->{thickness};
42 }
43  
44 4 ▶sub label {
Subroutine label: called CC=2 SCAR=7.2
Pod undocumented
45 4 my ($self) = @_;
46 return $self->{formula}
47 ? sprintf( '%s (%s)', $self->{pretty}, $self->{formula} )
48 4 ▶ : $self->{pretty};
Branch: 1 branch
BranchTrueFalseTotal
$self->{'formula'} ? : 4 0 4
49 }
50  
51 12 ▶sub _titlecase {
Subroutine _titlecase: called CC=1 SCAR=0.0
52 12 my ($s) = @_;
53 12 $s =~ s/_/ /g;
54 12 $s =~ s/\b(\w)/\U$1/g;
55 12 return $s;
56 }
57  
58 5 1;
59  
60 __END__
« Etch/WetEtch.pm ↑ Summary