OO/Lexicon/Role/StoreFile.pm

filter: Statementstmt 76.3% 29 / 38 Branchbran 16.6% 2 / 12 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 64.5% 40 / 62 CC 8 SCAR 30.3
CC
8
Cov
60%
store_content
38.1
BEGIN
1.0
BEGIN
1.0
CRAP 20.8
« OO/Translator.pm ↑ Summary OO/FunctionalInterface.pm »
1 package Locale::TextDomain::OO::Lexicon::Role::StoreFile; ## no critic (TidyCode)
2
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use English qw(-no_match_vars $OS_ERROR);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use MooX::Types::MooseLike::Base qw(Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10
11 2 our $VERSION = '1.017';
12
13 2 has filename => (
14 is => 'ro',
15 isa => Str,
16 );
17
18 2 has file_handle => (
19 is => 'ro',
20 ducktype => 'print',
21 );
22
23 26 ▶sub store_content {
Subroutine store_content: called CC=8 SCAR=36.4
Pod documented
24 26 my ($self, $content) = @_;
25
26 26 ▶ if ( $self->file_handle ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->file_handle) 0 26 26
27 0 my $quoted_filename = $self->filename;
28 0 ▶ $quoted_filename &&= qq{"$quoted_filename"};
Condition0%0/2
$quoted_filename &&= qq["$quoted_filename"]
!ll
00
MC/DC0%0/1
$quoted_filename &&= qq["$quoted_filename"]
$quoted_filename
Truth table0%0/2
A
A= $quoted_filename
Aresult
00
11
29 0 ▶ $self->file_handle->print( $self->file_handle, $content )
Branch: 1 branch
BranchTrueFalseTotal
$self->file_handle->print($self->file_handle, $content) or confess("Unable to print file$quoted_filename $Locale::TextDomain::OO::Lexicon::Role::StoreFile::OS_ERROR") 0 0 0
30 or confess qq{Unable to print file$quoted_filename $OS_ERROR};
31 0 return;
32 }
33 26 ▶ if ( $self->filename ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->filename) 0 26 26
34 0 my $filename = $self->filename;
35 0 ▶ open my $file_handle, q{> :raw}, $self->filename
Branch: 1 branch
BranchTrueFalseTotal
open my $file_handle, "> :raw", $self->filename or confess(qq[Unable to open file "$filename" $Locale::TextDomain::OO::Lexicon::Role::StoreFile::OS_ERROR]) 0 0 0
36 or confess qq{Unable to open file "$filename" $OS_ERROR};
37 0 ▶ $file_handle->print($content)
Branch: 1 branch
BranchTrueFalseTotal
$file_handle->print($content) or confess(qq[Unable to print file "$filename" $Locale::TextDomain::OO::Lexicon::Role::StoreFile::OS_ERROR]) 0 0 0
38 or confess qq{Unable to print file "$filename" $OS_ERROR};
39 0 ▶ $file_handle->close
Branch: 1 branch
BranchTrueFalseTotal
$file_handle->close or confess(qq[Unable to close file "$filename" $Locale::TextDomain::OO::Lexicon::Role::StoreFile::OS_ERROR]) 0 0 0
40 or confess qq{Unable to close file "$filename" $OS_ERROR};
41 0 return;
42 }
43
44 26 return $content;
45 }
46
47 2 1;
48
49 __END__
« OO/Translator.pm ↑ Summary OO/FunctionalInterface.pm »