lib/Perlmazing/Perlmazing/stat.pm

filter: Statementstmt 78.1% 25 / 32 Branchbran 50.0% 5 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 1 totaltotal 71.1% 37 / 52 CC 7 SCAR 9.7
CC
7
Cov
71%
AUTOLOAD
6.0
_stringify
3.0
new
3.0
CRAP 2.6
« blib/lib/Perlmazing/Perlmazing/get_aes_cipher.pm ↑ Summary lib/Perlmazing/Perlmazing/Precompile/merge.pm »
1 1 ▶use Perlmazing;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 1 ▶sub main {
Subroutine main: called CC=2 SCAR=8.1
Pod undocumented
4 1 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 1 1
5 0 return CORE::stat $_[0];
6 } else {
7 1 return Perlmazing::Object::Stat->new($_[0]);
8 }
9 }
10  
11 package Perlmazing::Object::Stat;
12 1 ▶use Perlmazing;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use overload fallback => 1, '""' => \&_stringify;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 our $AUTOLOAD;
15  
16 # These are just respecting the name given in the Perldoc for convienience:
17 my @keys = qw(
18 dev
19 ino
20 mode
21 nlink
22 uid
23 gid
24 rdev
25 size
26 atime
27 mtime
28 ctime
29 blksize
30 blocks
31 );
32  
33 1 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
34 1 my $self = shift;
35 1 my $file = shift;
36 1 my @stat = CORE::stat $file;
37 1 ▶ return unless @stat;
Branch: 1 branch
BranchTrueFalseTotal
unless @stat 0 1 1
38 1 my $this = {};
39 1 ▶ for (my $i = 0; $i < @stat; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @stat) 13 1 14
40 13 $this->{$keys[$i]} = $stat[$i];
41 }
42 1 bless $this, $self;
43 }
44  
45 1 ▶sub _stringify {
Subroutine _stringify: called CC=3 SCAR=11.1
46 1 my $self = shift;
47 1 my $string = '';
48 1 for my $i (@keys) {
49 1 ▶ return 1 if defined $self->{$i};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{$i} 1 0 1
50 }
51 }
52  
53 1 ▶sub _keys {
Subroutine _keys: called CC=1 SCAR=0.0
54 1 my @copy = @keys;
55 1 return @copy;
56 }
57  
58 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=2 SCAR=17.9
59 0 (my $name = $AUTOLOAD) =~ s/^.+:://;
60 0 my $self = shift;
61 0 ▶ if (exists $self->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{$name}) { } 0 0 0
62 0 return $self->{$name};
63 } else {
64 0 my @call = caller;
65 0 die qq[Can't locate object method "$name" via package "].__PACKAGE__.qq[" at $call[1] line $call[2].\nTip: valid methods are ].join(', ', @keys)."\n";
66 }
67 }
68  
69 0 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
70  
71 1;
« blib/lib/Perlmazing/Perlmazing/get_aes_cipher.pm ↑ Summary lib/Perlmazing/Perlmazing/Precompile/merge.pm »