File Coverage

blib/lib/App/iTan/Command/Delete.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             # ================================================================
2             package App::iTan::Command::Delete;
3             # ================================================================
4 1     1   1158 use utf8;
  1         1  
  1         4  
5 1     1   423 use Moose;
  0            
  0            
6             use 5.0100;
7              
8             our $VERSION = $App::iTan::VERSION;
9              
10             use MooseX::App::Command;
11             with qw(App::iTan::Utils);
12              
13             sub execute {
14             my ( $self, $opts, $args ) = @_;
15            
16             say 'All unused iTANs have been deleted';
17            
18             $self->dbh->do('DELETE FROM itan
19             WHERE valid = 0
20             AND used IS NULL')
21             or die "ERROR: Cannot execute: " . $self->dbh->errstr();
22            
23             return;
24             }
25              
26             __PACKAGE__->meta->make_immutable;
27             1;
28              
29             =pod
30              
31             =encoding utf8
32              
33             =head1 NAME
34              
35             App::iTan::Command::Delete - Delete all invalid iTANs
36              
37             =head1 SYNOPSIS
38              
39             itan delete
40              
41             =head1 DESCRIPTION
42              
43             Delete all invalid iTANs that have not been used yet
44              
45             =cut