| 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
| |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | return $self->{string} // confess 'BUG: No valid string'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"string"} // confess("BUG: No valid string")
MC/DC0%0/1
$self->{"string"} // confess("BUG: No valid string")
$self->{"string"}
Truth table0%0/2
A
A= $self->{"string"}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | return 1 if !defined($self) && !defined($other); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self or defined $other
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
| |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | return undef unless defined($self) && defined($other); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self and defined $other
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
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | croak 'Invalid input' unless defined Scalar::Util::blessed($self); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | croak 'Invalid input' unless defined Scalar::Util::blessed($other); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | return Scalar::Util::refaddr($self) == Scalar::Util::refaddr($other); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | # ---- Private helpers ---- | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 1 | 1; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | __END__ | ||||||||||||||||||||||||||||