| 1 | package File::KDBX::Object; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: A KDBX database object | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 14 | ▶ | use Devel::GlobalDestruction; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 14 | ▶ | use File::KDBX::Constants qw(:bool); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 14 | ▶ | use File::KDBX::Error; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 14 | ▶ | use File::KDBX::Util qw(:uuid); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 14 | ▶ | use Hash::Util::FieldHash qw(fieldhashes); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 14 | ▶ | use List::Util qw(any first); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 14 | ▶ | use Ref::Util qw(is_arrayref is_plain_arrayref is_plain_hashref is_ref); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 14 | ▶ | use Scalar::Util qw(blessed weaken); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 14 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 14 | our $VERSION = '0.905'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 14 | fieldhashes \my (%KDBX, %PARENT, %TXNS, %REFS, %SIGNALS); | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 237 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=23.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # copy constructor | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 237 | ▶ | return $_[0]->clone if @_ == 1 && blessed $_[0] && $_[0]->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@_ == 1 and builtin::blessed($_[0]) and $_[0]->isa($class)
@_ == 1 and builtin::blessed($_[0])
MC/DC0%0/3
@_ == 1 and builtin::blessed($_[0]) and $_[0]->isa($class)
@_ == 1
builtin::blessed($_[0])
$_[0]->isa($class)
Truth table75%3/4
A and B and C
A= @_ == 1B= builtin::blessed($_[0])C= $_[0]->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 237 | my $data; | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | 237 | ▶ | $data = shift if is_plain_hashref($_[0]); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 237 | my $kdbx; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | 237 | ▶ | $kdbx = shift if @_ % 2 == 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 237 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | 237 | ▶ | $args{kdbx} //= $kdbx if defined $kdbx; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{"kdbx"} //= $kdbx
MC/DC0%0/2
$args{"kdbx"} //= $kdbx
$args{"kdbx"}
$kdbx
Truth table33%1/3
A //= B
A= $args{"kdbx"}B= $kdbx
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 237 | ▶ | my $self = bless $data // {}, $class; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$data // {}
MC/DC100%1/1
$data // {}
$data
Truth table100%2/2
A
A= $data
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 237 | $self->init(%args); | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | 237 | ▶ | $self->_set_nonlazy_attributes if !$data; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 237 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub _set_nonlazy_attributes { die 'Not implemented' } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_nonlazy_attributes: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 133 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 133 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 133 | ▶ | while (my ($key, $val) = each %args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 331 | ▶ | if (my $method = $self->can($key)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 331 | $self->$method($val); | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 133 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | sub wrap { | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 798 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wrap: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 798 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | 798 | ▶ | return $object if blessed $object && $object->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($object) and $object->isa($class)
MC/DC50%1/2
builtin::blessed($object) and $object->isa($class)
builtin::blessed($object)
$object->isa($class)
Truth table66%2/3
A and B
A= builtin::blessed($object)B= $object->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 114 | ▶ | return $class->new(@_, @$object) if is_arrayref($object); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 72 | return $class->new($object, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub label { die 'Not implemented' } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 14 | my %CLONE = (entries => 1, groups => 1, history => 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | sub clone { | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 31 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=12 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 31 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 31 | ▶ | local $CLONE{new_uuid} = $args{new_uuid} // $args{parent} // 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
($args{"new_uuid"} // $args{"parent"}) // 0
$args{"new_uuid"} // $args{"parent"}
MC/DC100%2/2
($args{"new_uuid"} // $args{"parent"}) // 0
$args{"new_uuid"}
$args{"parent"}
Truth table100%3/3
A // B
A= $args{"new_uuid"}B= $args{"parent"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 31 | ▶ | local $CLONE{entries} = $args{entries} // 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"entries"} // 1
MC/DC100%1/1
$args{"entries"} // 1
$args{"entries"}
Truth table100%2/2
A
A= $args{"entries"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 31 | ▶ | local $CLONE{groups} = $args{groups} // 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"groups"} // 1
MC/DC100%1/1
$args{"groups"} // 1
$args{"groups"}
Truth table100%2/2
A
A= $args{"groups"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 31 | ▶ | local $CLONE{history} = $args{history} // 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"history"} // 1
MC/DC100%1/1
$args{"history"} // 1
$args{"history"}
Truth table100%2/2
A
A= $args{"history"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 31 | ▶ | local $CLONE{reference_password} = $args{reference_password} // 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"reference_password"} // 0
MC/DC0%0/1
$args{"reference_password"} // 0
$args{"reference_password"}
Truth table50%1/2
A
A= $args{"reference_password"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 31 | ▶ | local $CLONE{reference_username} = $args{reference_username} // 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"reference_username"} // 0
MC/DC100%1/1
$args{"reference_username"} // 0
$args{"reference_username"}
Truth table100%2/2
A
A= $args{"reference_username"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 31 | require Storable; | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | 31 | my $copy = Storable::dclone($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 31 | ▶ | if ($args{relabel} and my $label = $self->label) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args{"relabel"} and my $label = $self->label
MC/DC50%1/2
$args{"relabel"} and my $label = $self->label
$args{"relabel"}
my $label = $self->label
Truth table66%2/3
A and B
A= $args{"relabel"}B= my $label = $self->label
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | $copy->label("$label - Copy"); | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 31 | ▶ | if ($args{parent} and my $parent = $self->group) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args{"parent"} and my $parent = $self->group
MC/DC50%1/2
$args{"parent"} and my $parent = $self->group
$args{"parent"}
my $parent = $self->group
Truth table66%2/3
A and B
A= $args{"parent"}B= my $parent = $self->group
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 3 | $parent->add_object($copy); | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 31 | return $copy; | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | sub STORABLE_freeze { | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 64 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_freeze: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 64 | my $cloning = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 64 | my $copy = {%$self}; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | 64 | ▶ | delete $copy->{entries} if !$CLONE{entries}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 64 | ▶ | delete $copy->{groups} if !$CLONE{groups}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 64 | ▶ | delete $copy->{history} if !$CLONE{history}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 64 | ▶ | return ($cloning ? Hash::Util::FieldHash::id($self) : ''), $copy; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | sub STORABLE_thaw { | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 64 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_thaw: called CC=11 SCAR=24.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 64 | my $cloning = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | 64 | my $addr = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | 64 | my $copy = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 64 | @$self{keys %$copy} = values %$copy; | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 64 | ▶ | if ($cloning) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 64 | my $kdbx = $KDBX{$addr}; | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | 64 | ▶ | $self->kdbx($kdbx) if $kdbx; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 64 | ▶ | if (defined $self->{uuid}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 64 | ▶ | if (($CLONE{reference_password} || $CLONE{reference_username}) && $self->can('strings')) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$CLONE{"reference_password"} || $CLONE{"reference_username"} and $self->can("strings")
$CLONE{"reference_password"} or $CLONE{"reference_username"}
MC/DC33%1/3
$CLONE{"reference_password"} || $CLONE{"reference_username"} and $self->can("strings")
$CLONE{"reference_password"}
$CLONE{"reference_username"}
$self->can("strings")
Truth table40%2/5
A or B and C
A= $CLONE{"reference_password"}B= $CLONE{"reference_username"}C= $self->can("strings")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | my $uuid = format_uuid($self->{uuid}); | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | my $clone_obj = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | 2 | local $CLONE{new_uuid} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | local $CLONE{entries} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | local $CLONE{groups} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | local $CLONE{history} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | local $CLONE{reference_password} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | local $CLONE{reference_username} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | # Clone only the entry's data and manually bless to avoid infinite recursion. | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | bless Storable::dclone({%$copy}), 'File::KDBX::Entry'; | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | my $txn = $self->begin_work(snapshot => $clone_obj); | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 2 | ▶ | if ($CLONE{reference_password}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $self->password("{REF:P\@I:$uuid}"); | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | if ($CLONE{reference_username}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | $self->username("{REF:U\@I:$uuid}"); | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | $txn->commit; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 64 | ▶ | $self->uuid(generate_uuid) if $CLONE{new_uuid}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # Dualvars aren't cloned as dualvars, so dualify the icon. | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 64 | ▶ | $self->icon_id($self->{icon_id}) if defined $self->{icon_id}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | sub kdbx { | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 978 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
kdbx: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 978 | ▶ | $self = $self->new if !ref $self; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 978 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 310 | ▶ | if (my $kdbx = shift) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 310 | $KDBX{$self} = $kdbx; | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | 310 | weaken $KDBX{$self}; | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | delete $KDBX{$self}; | |||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 978 | ▶ | $KDBX{$self} or throw 'Object is disconnected', object => $self; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | sub is_connected { | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 84 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_connected: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 84 | return !!eval { $self->kdbx }; | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 5 | ▶ | sub id { format_uuid(shift->uuid, @_) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | sub group { | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 154 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
group: called CC=8 SCAR=21.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 154 | ▶ | if (my $new_group = shift) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | my $old_group = $self->group; | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | ▶ | return $new_group if Hash::Util::FieldHash::id($old_group) == Hash::Util::FieldHash::id($new_group); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # move to a new parent | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | $self->remove(signal => 0) if $old_group; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | $self->location_changed('now'); | |||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | $new_group->add_object($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 154 | my $id = Hash::Util::FieldHash::id($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | 154 | ▶ | if (my $group = $PARENT{$self}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 31 | my $method = $self->_parent_container; | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | 31 | ▶ | return $group if first { $id == Hash::Util::FieldHash::id($_) } @{$group->$method}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | delete $PARENT{$self}; | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # always get lineage from root to leaf because the other way requires parent, so it would be recursive | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 123 | ▶ | my $lineage = $self->kdbx->_trace_lineage($self) or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | my $group = pop @$lineage or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | $PARENT{$self} = $group; weaken $PARENT{$self}; | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | return $group; | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | sub _set_group { | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 110 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_group: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 110 | ▶ | if (my $parent = shift) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 48 | $PARENT{$self} = $parent; | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | 48 | weaken $PARENT{$self}; | |||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 62 | delete $PARENT{$self}; | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 110 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ### Name of the parent attribute expected to contain the object | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | sub _parent_container { die 'Not implemented' } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parent_container: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | sub lineage { | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lineage: called CC=7 SCAR=21.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 5 | my $base = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 5 | ▶ | my $base_addr = $base ? Hash::Util::FieldHash::id($base) : 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # try leaf to root | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 5 | my @path; | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | 5 | my $object = $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | 5 | ▶ | while ($object = $object->group) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 8 | unshift @path, $object; | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | 8 | ▶ | last if $base_addr == Hash::Util::FieldHash::id($object); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 5 | ▶ | return \@path if @path && ($base_addr == Hash::Util::FieldHash::id($path[0]) || $path[0]->is_root); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
@path and $base_addr == &Hash::Util::FieldHash::id($path[0]) || $path[0]->is_root
$base_addr == &Hash::Util::FieldHash::id($path[0]) or $path[0]->is_root
MC/DC0%0/3
@path and $base_addr == &Hash::Util::FieldHash::id($path[0]) || $path[0]->is_root
@path
$base_addr == &Hash::Util::FieldHash::id($path[0])
$path[0]->is_root
Truth table25%1/4
A and B or C
A= @pathB= $base_addr == &Hash::Util::FieldHash::id($path[0])C= $path[0]->is_root
| |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # try root to leaf | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | return $self->kdbx->_trace_lineage($self, $base); | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | sub remove { | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 55 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 55 | my $parent = $self->group; | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | 55 | ▶ | $parent->remove_object($self, @_) if $parent; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 55 | $self->_set_group(undef); | |||||||||||||||||||||||||||||||||||||||||||||
| 243 | 55 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||
| 247 | sub recycle { | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recycle: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | return $self->group($self->kdbx->recycle_bin); | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | sub recycle_or_remove { | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recycle_or_remove: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 3 | my $kdbx = eval { $self->kdbx }; | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | 3 | ▶ | if ($kdbx && $kdbx->recycle_bin_enabled && !$self->is_recycled) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$kdbx and $kdbx->recycle_bin_enabled and not $self->is_recycled
$kdbx and $kdbx->recycle_bin_enabled
MC/DC0%0/3
$kdbx and $kdbx->recycle_bin_enabled and not $self->is_recycled
$kdbx
$kdbx->recycle_bin_enabled
not $self->is_recycled
Truth table25%1/4
A and B and not(C)
A= $kdbxB= $kdbx->recycle_bin_enabledC= not $self->is_recycled
| |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | $self->recycle; | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 2 | $self->remove; | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | sub is_recycled { | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_recycled: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 4 | ▶ | eval { $self->kdbx } or return FALSE; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 4 | ▶ | return !!($self->group && any { $_->is_recycle_bin } @{$self->lineage}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Condition100%3/3
$self->group && &any(sub {
$_->is_recycle_bin;
}
, @{$self->lineage;})
MC/DC0%0/2
$self->group && &any(sub {
$_->is_recycle_bin;
}
, @{$self->lineage;})
$self->group
&any(sub {
$_->is_recycle_bin;
}
, @{$self->lineage;})
Truth table33%1/3
A && B
A= $self->groupB= &any(sub {
$_->is_recycle_bin;
}
, @{$self->lineage;})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | sub tag_list { | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tag_list: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | return grep { $_ ne '' } split(/[,\.:;]|\s+/, trim($self->tags) // ''); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
trim($self->tags) // ""
MC/DC0%0/1
trim($self->tags) // ""
trim($self->tags)
Truth table0%0/2
A
A= trim($self->tags)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | sub custom_icon { | ||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 7 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
custom_icon: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 7 | my $kdbx = $self->kdbx; | |||||||||||||||||||||||||||||||||||||||||||||
| 283 | 7 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 4 | my $img = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | 4 | ▶ | my $uuid = defined $img ? $kdbx->add_custom_icon($img, @_) : undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 4 | ▶ | $self->icon_id(0) if $uuid; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 4 | $self->custom_icon_uuid($uuid); | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | 4 | return $img; | |||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 3 | return $kdbx->custom_icon_data($self->custom_icon_uuid); | |||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | sub custom_data { | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 517 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
custom_data: called CC=13 SCAR=26.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 517 | ▶ | $self->{custom_data} = shift if @_ == 1 && is_plain_hashref($_[0]); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 and Ref::Util::XS::is_plain_hashref($_[0])
MC/DC0%0/2
@_ == 1 and Ref::Util::XS::is_plain_hashref($_[0])
@_ == 1
Ref::Util::XS::is_plain_hashref($_[0])
Truth table66%2/3
A and B
A= @_ == 1B= Ref::Util::XS::is_plain_hashref($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 517 | ▶ | return $self->{custom_data} //= {} if !@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->{"custom_data"} //= {}
MC/DC100%1/1
$self->{"custom_data"} //= {}
$self->{"custom_data"}
Truth table100%2/2
A
A= $self->{"custom_data"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 19 | ▶ | my %args = @_ == 2 ? (key => shift, value => shift) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | : @_ % 2 == 1 ? (key => shift, @_) : @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 19 | ▶ | if (!$args{key} && !$args{value}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args{"key"} or $args{"value"}
MC/DC50%1/2
$args{"key"} or $args{"value"}
$args{"key"}
$args{"value"}
Truth table66%2/3
A or B
A= $args{"key"}B= $args{"value"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 2 | my %standard = (key => 1, value => 1, last_modification_time => 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | my @other_keys = grep { !$standard{$_} } keys %args; | |||||||||||||||||||||||||||||||||||||||||||||
| 305 | 2 | ▶ | if (@other_keys == 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | my $key = $args{key} = $other_keys[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | 2 | $args{value} = delete $args{$key}; | |||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 19 | ▶ | my $key = $args{key} or throw 'Must provide a custom_data key to access'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 19 | ▶ | return $self->{custom_data}{$key} = $args{value} if is_plain_hashref($args{value}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 19 | ▶ | while (my ($field, $value) = each %args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 34 | $self->{custom_data}{$key}{$field} = $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 19 | return $self->{custom_data}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | sub custom_data_value { | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
custom_data_value: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 6 | ▶ | my $data = $self->custom_data(@_) // return undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->custom_data(@_) // (return undef)
MC/DC0%0/1
$self->custom_data(@_) // (return undef)
$self->custom_data(@_)
Truth table50%1/2
A
A= $self->custom_data(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 6 | return $data->{value}; | |||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | sub begin_work { | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 35 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
begin_work: called CC=9 SCAR=22.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 35 | ▶ | if (defined wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 16 | require File::KDBX::Transaction; | |||||||||||||||||||||||||||||||||||||||||||||
| 336 | 16 | return File::KDBX::Transaction->new($self, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 19 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 340 | 19 | ▶ | my $orig = $args{snapshot} // do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args{"snapshot"} // do {
my $c = $self->clone("entries", $args{"entries"} // 0, "groups", $args{"groups"} // 0, "history", $args{"history"} // 0);
$c->{"entries"} = $self->{"entries"} unless $args{"entries"};
$c->{"groups"} = $self->{"groups"} unless $args{"groups"};
$c->{"history"} = $self->{"history"} unless $args{"history"};
$c
}
MC/DC0%0/2
$args{"snapshot"} // do {
my $c = $self->clone("entries", $args{"entries"} // 0, "groups", $args{"groups"} // 0, "history", $args{"history"} // 0);
$c->{"entries"} = $self->{"entries"} unless $args{"entries"};
$c->{"groups"} = $self->{"groups"} unless $args{"groups"};
$c->{"history"} = $self->{"history"} unless $args{"history"};
$c
}
$args{"snapshot"}
do {
my $c = $self->clone("entries", $args{"entries"} // 0, "groups", $args{"groups"} // 0, "history", $args{"history"} // 0);
$c->{"entries"} = $self->{"entries"} unless $args{"entries"};
$c->{"groups"} = $self->{"groups"} unless $args{"groups"};
$c->{"history"} = $self->{"history"} unless $args{"history"};
$c
}
Truth table66%2/3
A // B
A= $args{"snapshot"}B= do {
my $c = $self->clone("entries", $args{"entries"} // 0, "groups", $args{"groups"} // 0, "history", $args{"history"} // 0);
$c->{"entries"} = $self->{"entries"} unless $args{"entries"};
$c->{"groups"} = $self->{"groups"} unless $args{"groups"};
$c->{"history"} = $self->{"history"} unless $args{"history"};
$c
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | my $c = $self->clone( | ||||||||||||||||||||||||||||||||||||||||||||||
| 342 | entries => $args{entries} // 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | groups => $args{groups} // 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 17 | ▶ | history => $args{history} // 0, | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$args{"entries"} // 0
$args{"groups"} // 0
$args{"history"} // 0
MC/DC100%1/1
$args{"entries"} // 0
$args{"entries"}
MC/DC0%0/1
$args{"groups"} // 0
$args{"groups"}
MC/DC0%0/1
$args{"history"} // 0
$args{"history"}
Truth table100%2/2
A
A= $args{"entries"}
Truth table50%1/2
A
A= $args{"groups"}
Truth table50%1/2
A
A= $args{"history"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 17 | ▶ | $c->{entries} = $self->{entries} if !$args{entries}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 17 | ▶ | $c->{groups} = $self->{groups} if !$args{groups}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 17 | ▶ | $c->{history} = $self->{history} if !$args{history}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 17 | $c; | |||||||||||||||||||||||||||||||||||||||||||||
| 350 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 19 | my $id = Hash::Util::FieldHash::id($orig); | |||||||||||||||||||||||||||||||||||||||||||||
| 353 | 19 | _save_references($id, $self, $orig); | |||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 19 | $self->_signal_begin_work; | |||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 19 | push @{$self->_txns}, $orig; | |||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||
| 361 | sub commit { | ||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 14 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
commit: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 14 | ▶ | my $orig = pop @{$self->_txns} or return $self; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 14 | $self->_commit($orig); | |||||||||||||||||||||||||||||||||||||||||||||
| 365 | 14 | my $signals = $self->_signal_commit; | |||||||||||||||||||||||||||||||||||||||||||||
| 366 | 14 | ▶ | $self->_signal_send($signals) if !$self->_in_txn; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 14 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | sub rollback { | ||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rollback: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 5 | ▶ | my $orig = pop @{$self->_txns} or return $self; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 5 | my $id = Hash::Util::FieldHash::id($orig); | |||||||||||||||||||||||||||||||||||||||||||||
| 377 | 5 | _restore_references($id, $orig); | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 5 | $self->_signal_rollback; | |||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 5 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||
| 384 | # Get whether or not there is at least one pending transaction. | ||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 82 | ▶ | sub _in_txn { scalar @{$_[0]->_txns} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_in_txn: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # Get an array ref of pending transactions. | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 152 | ▶ | sub _txns { $TXNS{$_[0]} //= [] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_txns: called CC=2 SCAR=6.9
Condition100%2/2
$TXNS{$_[0]} //= []
MC/DC100%1/1
$TXNS{$_[0]} //= []
$TXNS{$_[0]}
Truth table100%2/2
A
A= $TXNS{$_[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||
| 390 | # The _commit hook notifies subclasses that a commit has occurred. | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | sub _commit { die 'Not implemented' } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_commit: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # Get a reference to an object that represents an object's committed state. If there is no pending | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | # transaction, this is just $self. If there is a transaction, this is the snapshot take before the transaction | ||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # began. This method is private because it provides direct access to the actual snapshot. It is important that | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | # the snapshot not be changed or a rollback would roll back to an altered state. | ||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # This is used by File::KDBX::Dumper::XML so as to not dump uncommitted changes. | ||||||||||||||||||||||||||||||||||||||||||||||
| 398 | sub _committed { | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 32 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_committed: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 32 | my ($orig) = @{$self->_txns}; | |||||||||||||||||||||||||||||||||||||||||||||
| 401 | 32 | ▶ | return $orig // $self; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$orig // $self
MC/DC0%0/2
$orig // $self
$orig
$self
Truth table66%2/3
A // B
A= $origB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # In addition to cloning an object when beginning work, we also keep track its hashrefs and arrayrefs | ||||||||||||||||||||||||||||||||||||||||||||||
| 405 | # internally so that we can restore to the very same structures in the case of a rollback. | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | sub _save_references { | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 1406 | ▶ | my $id = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_save_references: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 1406 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 409 | 1406 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 1406 | ▶ | if (is_plain_arrayref($orig)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 67 | ▶ | for (my $i = 0; $i < @$orig; ++$i) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 20 | _save_references($id, $self->[$i], $orig->[$i]); | |||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 67 | $REFS{$id}{Hash::Util::FieldHash::id($orig)} = $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 417 | ▶ | elsif (is_plain_hashref($orig) || (blessed $orig && $orig->isa(__PACKAGE__))) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
Ref::Util::XS::is_plain_hashref($orig) or builtin::blessed($orig) and $orig->isa(__PACKAGE__)
builtin::blessed($orig) and $orig->isa(__PACKAGE__)
MC/DC100%3/3
Ref::Util::XS::is_plain_hashref($orig) or builtin::blessed($orig) and $orig->isa(__PACKAGE__)
Ref::Util::XS::is_plain_hashref($orig)
builtin::blessed($orig)
$orig->isa(__PACKAGE__)
Truth table100%4/4
A or B and C
A= Ref::Util::XS::is_plain_hashref($orig)B= builtin::blessed($orig)C= $orig->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 349 | for my $key (keys %$orig) { | |||||||||||||||||||||||||||||||||||||||||||||
| 419 | 1367 | _save_references($id, $self->{$key}, $orig->{$key}); | |||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 349 | $REFS{$id}{Hash::Util::FieldHash::id($orig)} = $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # During a rollback, copy data from the snapshot back into the original internal structures. | ||||||||||||||||||||||||||||||||||||||||||||||
| 426 | sub _restore_references { | ||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 377 | ▶ | my $id = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_restore_references: called CC=9 SCAR=22.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 377 | ▶ | my $orig = shift // return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() // (return)
MC/DC100%1/1
shift() // (return)
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 329 | ▶ | my $self = delete $REFS{$id}{Hash::Util::FieldHash::id($orig) // ''} // return $orig; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
delete $REFS{$id}{&Hash::Util::FieldHash::id($orig) // ""} // (return $orig)
&Hash::Util::FieldHash::id($orig) // ""
MC/DC100%1/1
delete $REFS{$id}{&Hash::Util::FieldHash::id($orig) // ""} // (return $orig)
delete $REFS{$id}{&Hash::Util::FieldHash::id($orig) // ""}
MC/DC0%0/1
&Hash::Util::FieldHash::id($orig) // ""
&Hash::Util::FieldHash::id($orig)
Truth table100%2/2
A
A= delete $REFS{$id}{&Hash::Util::FieldHash::id($orig) // ""}
Truth table50%1/2
A
A= &Hash::Util::FieldHash::id($orig)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 108 | ▶ | if (is_plain_arrayref($orig)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 19 | @$self = map { _restore_references($id, $_) } @$orig; | |||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | ▶ | elsif (is_plain_hashref($orig) || (blessed $orig && $orig->isa(__PACKAGE__))) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
Ref::Util::XS::is_plain_hashref($orig) or builtin::blessed($orig) and $orig->isa(__PACKAGE__)
builtin::blessed($orig) and $orig->isa(__PACKAGE__)
MC/DC0%0/3
Ref::Util::XS::is_plain_hashref($orig) or builtin::blessed($orig) and $orig->isa(__PACKAGE__)
Ref::Util::XS::is_plain_hashref($orig)
builtin::blessed($orig)
$orig->isa(__PACKAGE__)
Truth table50%2/4
A or B and C
A= Ref::Util::XS::is_plain_hashref($orig)B= builtin::blessed($orig)C= $orig->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 89 | for my $key (keys %$orig) { | |||||||||||||||||||||||||||||||||||||||||||||
| 436 | # next if is_ref($orig->{$key}) && | ||||||||||||||||||||||||||||||||||||||||||||||
| 437 | # (Hash::Util::FieldHash::id($self->{$key}) // 0) == Hash::Util::FieldHash::id($orig->{$key}); | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 366 | $self->{$key} = _restore_references($id, $orig->{$key}); | |||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 108 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||
| 447 | sub _signal { | ||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 68 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_signal: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 68 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 68 | ▶ | if ($self->_in_txn) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $stack = $self->_signal_stack; | |||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my $queue = $stack->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | push @$queue, [$type, @_]; | |||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 68 | $self->_signal_send([[$type, @_]]); | |||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 68 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 52 | ▶ | sub _signal_stack { $SIGNALS{$_[0]} //= [] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_signal_stack: called CC=2 SCAR=6.9
Condition100%2/2
$SIGNALS{$_[0]} //= []
MC/DC100%1/1
$SIGNALS{$_[0]} //= []
$SIGNALS{$_[0]}
Truth table100%2/2
A
A= $SIGNALS{$_[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||
| 464 | sub _signal_begin_work { | ||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 19 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_signal_begin_work: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 19 | push @{$self->_signal_stack}, []; | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||
| 469 | sub _signal_commit { | ||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 14 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_signal_commit: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 14 | my $signals = pop @{$self->_signal_stack}; | |||||||||||||||||||||||||||||||||||||||||||||
| 472 | 14 | ▶ | my $previous = $self->_signal_stack->[-1] // []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->_signal_stack->[-1] // []
MC/DC100%1/1
$self->_signal_stack->[-1] // []
$self->_signal_stack->[-1]
Truth table100%2/2
A
A= $self->_signal_stack->[-1]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 14 | push @$previous, @$signals; | |||||||||||||||||||||||||||||||||||||||||||||
| 474 | 14 | return $previous; | |||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||
| 477 | sub _signal_rollback { | ||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_signal_rollback: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 5 | pop @{$self->_signal_stack}; | |||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||
| 482 | sub _signal_send { | ||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 80 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_signal_send: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 80 | ▶ | my $signals = shift // []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // []
MC/DC0%0/1
shift() // []
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 80 | ▶ | my $kdbx = $KDBX{$self} or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||
| 488 | # de-duplicate, keeping the most recent signal for each type | ||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 80 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||
| 490 | 80 | my @signals = grep { !$seen{$_->[0]}++ } reverse @$signals; | |||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 80 | for my $sig (reverse @signals) { | |||||||||||||||||||||||||||||||||||||||||||||
| 493 | 68 | $kdbx->_handle_signal($self, @$sig); | |||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||
| 497 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||
| 499 | sub _wrap_group { | ||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 54 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_wrap_group: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 54 | my $group = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 502 | 54 | require File::KDBX::Group; | |||||||||||||||||||||||||||||||||||||||||||||
| 503 | 54 | return File::KDBX::Group->wrap($group, $KDBX{$self}); | |||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||
| 506 | sub _wrap_entry { | ||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 59 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_wrap_entry: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 59 | my $entry = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 509 | 59 | require File::KDBX::Entry; | |||||||||||||||||||||||||||||||||||||||||||||
| 510 | 59 | return File::KDBX::Entry->wrap($entry, $KDBX{$self}); | |||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | sub TO_JSON { +{%{$_[0]}} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 14 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||
| 517 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||