Interface/Word.pm

filter: Statementstmt 32.2% 19 / 59 Branchbran 0.0% 0 / 40 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 66.6% 6 / 9 Podpod 100% 3 / 3 totaltotal 21.3% 28 / 131 CC 25 SCAR 43.0
CC
25
Cov
17%
new
90.0
eq
90.0
cmp
90.0
CRAP 73.8
↑ Summary Interface.pm »
1 # Copyright (c) 2026 Philipp Schafft
2  
3 # licensed under Artistic License 2.0 (see LICENSE file)
4  
5 # ABSTRACT: module to interact with the words of any language
6  
7  
8 package Lingua::Generic::Interface::Word;
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 Data::Identifier v0.34;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 our $VERSION = v0.03;
18  
19 1 ▶use parent 'Lingua::Generic::Interface::Element';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21  
22 0 ▶sub new {
Subroutine new: not called CC=9 SCAR=45.0
Pod documented
23 0 my ($pkg, $type, $value, @opts) = @_;
24  
25 0 ▶ croak 'No type given' unless defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 0 0
26 0 ▶ croak 'No value given' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
27 0 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 0 0
28  
29 0 ▶ if ($type eq 'from') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'from') { } 0 0 0
elsif ($type eq 'ise') { } 0 0 0
30 0 ▶ if (ref $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) { } 0 0 0
31 0 ▶ if ($value->isa(__PACKAGE__)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa(__PACKAGE__)) { } 0 0 0
32 0 return $value;
33 } else {
34 ...
35 0 }
36 } else {
37 0 $type = 'string';
38 }
39 } elsif ($type eq 'ise') {
40 ...
41 0 }
42  
43 0 ▶ if ($type eq 'string') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'string') { } 0 0 0
44 0 return bless {
45 string => $value,
46 }, $pkg;
47 } else {
48 0 croak 'Bad type: '.$type;
49 }
50 }
51  
52  
53 0 ▶sub eq {
Subroutine eq: not called CC=9 SCAR=45.0
Pod documented
54 0 my ($self, $other, @opts) = @_;
55  
56 0 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 0 0
57  
58 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
59 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
60  
61 0 ▶ $self = __PACKAGE__->new(from => $self) unless eval {$self->isa(__PACKAGE__)};
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { $self->isa(__PACKAGE__) } } 0 0 0
62 0 ▶ $other = __PACKAGE__->new(from => $other) unless eval {$other->isa(__PACKAGE__)};
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { $other->isa(__PACKAGE__) } } 0 0 0
63  
64 0 ▶ return undef unless ref($self) eq ref($other);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self eq ref $other 0 0 0
65  
66 0 return $self->as_string eq $other->as_string;
67 }
68  
69  
70 0 ▶sub cmp {
Subroutine cmp: not called CC=9 SCAR=45.0
Pod documented
71 0 my ($self, $other, @opts) = @_;
72  
73 0 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 0 0
74  
75 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
76 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
77  
78 0 ▶ $self = __PACKAGE__->new(from => $self) unless eval {$self->isa(__PACKAGE__)};
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { $self->isa(__PACKAGE__) } } 0 0 0
79 0 ▶ $other = __PACKAGE__->new(from => $other) unless eval {$other->isa(__PACKAGE__)};
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { $other->isa(__PACKAGE__) } } 0 0 0
80  
81 {
82 0 my $v = ref($self) cmp ref($other);
83 0 ▶ return $v if $v != 0;
Branch: 1 branch
BranchTrueFalseTotal
if $v != 0 0 0 0
84 }
85  
86 {
87 0 my $str_self = $self->as_string;
88 0 my $str_other = $other->as_string;
89  
90 0 return $str_self cmp $str_other;
91 }
92  
93 0 croak 'BUG!';
94 }
95  
96  
97  
98  
99  
100 # ---- Private helpers ----
101  
102 1 1;
103  
104 __END__
↑ Summary Interface.pm »