lib/Lingua/Lapine/Word.pm

filter: Statementstmt 73.5% 39 / 53 Branchbran 25.0% 5 / 20 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 83.3% 10 / 12 Podpod 100% 3 / 3 totaltotal 60.2% 59 / 98 CC 13 SCAR 25.1
CC
13
Cov
58%
new
22.4
_known_provider
20.0
register
2.1
CRAP 12.3
↑ Summary
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 Lapine
6  
7  
8 package Lingua::Lapine::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.01;
18  
19 1 ▶use parent qw(Data::Identifier::Interface::Known Lingua::Generic::Interface::Word);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 WK_LT_LAPINE => Data::Identifier->new(uuid => '8ca63437-1b1e-4a85-8512-02ba5c15a412', displayname => 'Lapine')->register,
23 1 };
24  
25 1 my %_registered_by_string;
26  
27 1 my @_wellknown_words = map {__PACKAGE__->new(string => $_)->register} (
28 qw(elil embleer flay flayrah Frith fu hlao hlessi homba hrair hraka hrududu lendri marli narn Ni-Frith owsla owslafa pfeffa rah roo silf tharn thlay threar vair yona zorn), # generic
29 1 ▶ qw(Efrafa El-ahrairah Hlao-roo Hrairoo Hyzenthlay Nildro-hain Sayn Thethuthinnang Thlayli), "Inl\N{LATIN SMALL LETTER E WITH ACUTE}", # names
Subroutine BEGIN: called CC=1 SCAR=0.0
30 );
31  
32  
33 # Not our actual constructor, see _new(). This is for the public API only
34 38 ▶sub new {
Subroutine new: called CC=9 SCAR=31.1
Pod documented
35 38 my ($pkg, $type, $value, @opts) = @_;
36  
37 38 ▶ croak 'No type given' unless defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 38 38
38 38 ▶ croak 'No value given' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 38 38
39 38 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 38 38
40  
41 38 ▶ if ($type eq 'from') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "from") 0 38 38
42 0 ▶ if (ref $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) { } 0 0 0
43 0 ▶ if ($value->isa(__PACKAGE__)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa(__PACKAGE__)) { } 0 0 0
44 0 return $value;
45 } else {
46 ...
47 0 }
48 } else {
49 0 $type = 'string';
50 }
51 }
52  
53 38 ▶ if ($type eq 'string') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'string') { } 38 0 38
54 38 $value =~ s/^inle\z/Inl\N{LATIN SMALL LETTER E WITH ACUTE}/i; # normalise name
55 38 ▶ return $_registered_by_string{fc $value} // $pkg->SUPER::new(string => $value);
Condition33%1/3
$_registered_by_string{fc $value} // $pkg->SUPER::new("string", $value)
l!l&&r!l&&!r
0380
MC/DC0%0/2
$_registered_by_string{fc $value} // $pkg->SUPER::new("string", $value)
$_registered_by_string{fc $value} $pkg->SUPER::new("string", $value)
Truth table33%1/3
A // B
A= $_registered_by_string{fc $value}B= $pkg->SUPER::new("string", $value)
ABresult
1X1
011
000
56 } else {
57 0 croak 'Bad type: '.$type;
58 }
59 }
60  
61  
62 #@returns Data::Identifier
63 0 ▶sub natural_language {
Subroutine natural_language: not called CC=1 SCAR=6.9
Pod documented
64 0 my ($self) = @_;
65 0 return WK_LT_LAPINE;
66 }
67  
68  
69 #@returns __PACKAGE__
70 38 ▶sub register {
Subroutine register: called CC=2 SCAR=7.6
Pod documented
71 38 my ($self) = @_;
72  
73 38 ▶ $_registered_by_string{fc $self->as_string} //= $self;
Condition33%1/3
$_registered_by_string{fc $self->as_string} //= $self
l!l&&r!l&&!r
0380
MC/DC0%0/2
$_registered_by_string{fc $self->as_string} //= $self
$_registered_by_string{fc $self->as_string} $self
Truth table33%1/3
A //= B
A= $_registered_by_string{fc $self->as_string}B= $self
ABresult
1X1
011
000
74  
75 38 return $self;
76 }
77  
78 # ---- Overridden methods ----
79  
80  
81  
82 # ---- Private helpers ----
83  
84  
85 0 ▶sub _known_provider {
Subroutine _known_provider: not called CC=4 SCAR=30.0
86 0 my ($pkg, $class, %opts) = @_;
87  
88 0 ▶ croak 'Unsupported options passed' if scalar(keys %opts);
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 0 0
89  
90 0 ▶ if ($class eq 'word') {
Branch: 2 branches
BranchTrueFalseTotal
if ($class eq 'word') { } 0 0 0
elsif ($class eq ':all') { } 0 0 0
91 0 return (\@_wellknown_words, rawtype => __PACKAGE__);
92 } elsif ($class eq ':all') {
93 return ([
94 0 @_wellknown_words,
95 WK_LT_LAPINE,
96 ], rawtype => 'Data::Identifier::Interface::Simple');
97 }
98  
99 0 croak 'Unsupported class';
100 }
101  
102 1 1;
103  
104 __END__
↑ Summary