Common/Handle.pm

filter: Statementstmt 72.4% 42 / 58 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 78.5% 11 / 14 Podpod 0.0% 0 / 2 totaltotal 66.2% 53 / 80 CC 5 SCAR 14.7
CC
5
Cov
66%
autoflush
12.0
AUTOLOAD
10.1
charset
1.3
CRAP 4.4
« Common.pm ↑ Summary Common/Base.pm »
1 1 ▶use Object::Pad ':experimental(:all)';
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package IO::Handle::Common::Handle;
4  
5 class IO::Handle::Common::Handle;
6  
7 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use v5.40;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶no warnings 'experimental::re_strict';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use re 'strict';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use Const::Fast;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Unicode::UTF8;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use List::Util 'none';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Path::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use FileHandle;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 const our $DEFAULT_LAYER => 'encoding(UTF-8)';
20  
21 1 ▶use open ':std', IO => $DEFAULT_LAYER;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 field $charset : param = 'UTF-8';
24 1 field $fileno;
25 field $handle : reader(charset)
26 0 ▶ ; # TODO: decipher AUTOLOAD logic that led to charset reader here
Subroutine charset: not called CC=1 SCAR=2.6
Pod undocumented
27 1 field $path;
28 field $mode : param = ">";
29 1 field $autoflush : param = 1;
30  
31 1 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=3 SCAR=23.1
32 0 our $AUTOLOAD;
33  
34 0 my $invoke = shift;
35 0 const my $meth_re => qr!^.*::!;
36 0 my $method = ( $AUTOLOAD =~ s/$meth_re//r );
37  
38 0 ▶ if ( $invoke->isa('IO::Handle::Common::Handle') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($invoke->isa('IO::Handle::Common::Handle')) { } 0 0 0
39 0 ▶ if ( my $charset = $invoke->charset ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $charset = $invoke->charset) 0 0 0
40 0 $invoke->charset->$method(@_);
41 }
42 }
43 else {
44 0 die "No class common method '$method' ($AUTOLOAD)";
45 }
46 }
47  
48 1 ADJUST : params (:$fn //= undef, :$fh //= undef, :$fd //= undef) {
49 my @arg = ( $fn, $fh, $fd );
50  
51 die "Only one of the following can be defined: \$fn, \$fh, \$fd"
52 if scalar( ( grep { defined $_ } @arg ) > 1 );
53  
54 if ($fn) {
55 $path = path($fn);
56 $handle = $path->filehandle($mode);
57 }
58 elsif ($fh) {
59 $handle = $fh;
60 $fileno = fileno($fh);
61 }
62 elsif ($fd) {
63 $handle = FileHandle->new_from_fd( $fd, $mode );
64 $handle->binmode($IO::Handle::Common::Handle::DEFAULT_LAYER);
65 $fileno = $fd;
66 }
67  
68 $handle->autoflush($autoflush) if $handle
69 };
70  
71 0 ▶method autoflush ( $enable = 1 ) {
Subroutine autoflush: not called CC=3 SCAR=24.8
Pod undocumented
72 0 ▶ $autoflush = $enable if $autoflush != $enable;
Branch: 1 branch
BranchTrueFalseTotal
if $autoflush != $enable 0 0 0
73 0 $handle->autoflush($autoflush);
74 1 }
75  
76 method default_layer : common {
77 $DEFAULT_LAYER;
78 }
« Common.pm ↑ Summary Common/Base.pm »