Interface/Base.pm

filter: Statementstmt 52.0% 25 / 48 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 50.0% 8 / 16 Podpod 100% 4 / 4 totaltotal 38.1% 37 / 97 CC 12 SCAR 32.1
CC
12
Cov
35%
eq
72.0
as_string
12.0
displayname
12.0
CRAP 24.7
« Interface.pm ↑ Summary Interface/Fragment.pm »
1 # Copyright (c) 2026 Philipp Schafft
2  
3 # licensed under Artistic License 2.0 (see LICENSE file)
4  
5 # ABSTRACT: base module used by language independent linguistic interfaces
6  
7  
8 package Lingua::Generic::Interface::Base;
9  
10 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Data::Identifier v0.34;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 our $VERSION = v0.03;
19  
20 1 ▶use parent qw(Data::Identifier::Interface::Subobjects Data::Identifier::Interface::Simple);
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶use overload (
Subroutine BEGIN: called CC=1 SCAR=1.7
23 0 ▶ '""' => sub { $_[0]->as_string },
Subroutine __ANON__: not called CC=1 SCAR=6.9
24 0 ▶ 'eq' => sub { $_[0]->eq($_[1]) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
25 0 ▶ 'ne' => sub { !$_[0]->eq($_[1]) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 ▶ 'cmp' => sub { $_[0]->cmp($_[1]) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 1 );
28  
29  
30  
31 0 ▶sub as_string {
Subroutine as_string: not called CC=3 SCAR=24.8
Pod documented
32 0 my ($self, @opts) = @_;
33 0 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 0 0
34 0 ▶ return $self->{string} // confess 'BUG: No valid string';
Condition0%0/2
$self->{"string"} // confess("BUG: No valid string")
l!l
00
MC/DC0%0/1
$self->{"string"} // confess("BUG: No valid string")
$self->{"string"}
Truth table0%0/2
A
A= $self->{"string"}
Aresult
11
00
35 }
36  
37  
38 0 ▶sub displayname {
Subroutine displayname: not called CC=3 SCAR=24.8
Pod documented
39 0 my ($self, @opts) = @_;
40 0 ▶ return $self->as_string if scalar(@opts) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts == 0 0 0 0
41 { # work around the case we have no working $self->as().
42 0 my %x = @opts;
43 0 delete $x{default};
44 0 delete $x{no_defaults};
45 0 ▶ return $self->as_string if scalar(keys %x) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %x == 0 0 0 0
46 }
47 0 return $self->as('Data::Identifier')->displayname(@opts);
48 }
49  
50  
51 0 ▶sub ise {
Subroutine ise: not called CC=1 SCAR=6.9
Pod documented
52 ...
53 0 }
54  
55  
56 0 ▶sub eq {
Subroutine eq: not called CC=8 SCAR=42.8
Pod documented
57 0 my ($self, $other, @opts) = @_;
58  
59 0 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 0 0
60  
61 0 ▶ return 1 if !defined($self) && !defined($other);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self or defined $other 0 0 0
Condition0%0/3
defined $self or defined $other
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $self or defined $other
defined $self defined $other
Truth table0%0/3
A or B
A= defined $selfB= defined $other
ABresult
1X1
011
000
62 0 ▶ return undef unless defined($self) && defined($other);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self and defined $other 0 0 0
Condition0%0/3
defined $self and defined $other
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self and defined $other
defined $self defined $other
Truth table0%0/3
A and B
A= defined $selfB= defined $other
ABresult
0X0
100
111
63  
64 0 ▶ croak 'Invalid input' unless defined Scalar::Util::blessed($self);
Branch: 1 branch
BranchTrueFalseTotal
unless defined builtin::blessed($self) 0 0 0
65 0 ▶ croak 'Invalid input' unless defined Scalar::Util::blessed($other);
Branch: 1 branch
BranchTrueFalseTotal
unless defined builtin::blessed($other) 0 0 0
66  
67 0 return Scalar::Util::refaddr($self) == Scalar::Util::refaddr($other);
68 }
69  
70 # ---- Private helpers ----
71  
72 1 1;
73  
74 __END__
« Interface.pm ↑ Summary Interface/Fragment.pm »