| 1 | 5 | ▶ | use 5.20.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package DBIx::Class::Smooth::Helper::Util; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # ABSTRACT: Short intro | ||||||||||||||||||||||||||||
| 8 | 5 | our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY | |||||||||||||||||||||||||||
| 9 | 5 | our $VERSION = '0.0104'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 5 | use Sub::Exporter::Progressive -setup => { | |||||||||||||||||||||||||||
| 13 | exports => [ | ||||||||||||||||||||||||||||
| 14 | qw( | ||||||||||||||||||||||||||||
| 15 | result_source_to_relation_name | ||||||||||||||||||||||||||||
| 16 | result_source_to_class | ||||||||||||||||||||||||||||
| 17 | clean_source_name | ||||||||||||||||||||||||||||
| 18 | ), | ||||||||||||||||||||||||||||
| 19 | ], | ||||||||||||||||||||||||||||
| 20 | 5 | ▶ | }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 5 | ▶ | use experimental qw/signatures/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 22 | ▶ | sub result_source_to_relation_name($result_source_name, $plural = 0) { | ||||||||||||||||||||||||||
|
Subroutine
result_source_to_relation_name: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 22 | my $relation_name = clean_source_name($result_source_name); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 22 | $relation_name =~ s{::}{_}g; | |||||||||||||||||||||||||||
| 27 | 22 | my @parts = split /\|/, $relation_name, 2; | |||||||||||||||||||||||||||
| 28 | 22 | $relation_name = $parts[-1]; | |||||||||||||||||||||||||||
| 29 | 22 | $relation_name = String::CamelCase::decamelize($relation_name); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 22 | ▶ | return $relation_name.($plural && substr ($relation_name, -1, 1) ne 's' ? 's' : ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$plural and substr($relation_name, -1, 1) ne "s"
MC/DC50%1/2
$plural and substr($relation_name, -1, 1) ne "s"
$plural
substr($relation_name, -1, 1) ne "s"
Truth table66%2/3
A and B
A= $pluralB= substr($relation_name, -1, 1) ne "s"
| |||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | ▶ | sub result_source_to_class($calling_class, $other_result_source) { | |||||||||||||||||||||||||||
|
Subroutine
result_source_to_class: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | 10 | $other_result_source =~ s{\|}{}; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | # Make it possible to use fully qualified result sources, with a leading hât ("^Fully::Qualified::Result::Source"). | ||||||||||||||||||||||||||||
| 37 | 10 | ▶ | return substr($other_result_source, 1) if substr($other_result_source, 0, 1) eq '^'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 10 | return base_namespace($calling_class) . clean_source_name($other_result_source); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | ▶ | sub base_namespace($class) { | |||||||||||||||||||||||||||
|
Subroutine
base_namespace: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 10 | $class =~ m{^(.*?::Result::)}; | |||||||||||||||||||||||||||
| 42 | 10 | return $1; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | ▶ | sub clean_source_name($source_name) { | |||||||||||||||||||||||||||
|
Subroutine
clean_source_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 32 | $source_name =~ s{^.*?::Result::}{}; | |||||||||||||||||||||||||||
| 46 | 32 | return $source_name; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 5 | 1; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =pod | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =head1 NAME | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | DBIx::Class::Smooth::Helper::Util - Short intro | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head1 VERSION | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | Version 0.0104, released 2020-08-30. | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =head1 SOURCE | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | L<https://github.com/Csson/p5-DBIx-Class-Smooth> | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =head1 HOMEPAGE | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | L<https://metacpan.org/release/DBIx-Class-Smooth> | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | Erik Carlsson <info@code301.com> | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | This software is copyright (c) 2018 by Erik Carlsson. | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 82 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =cut | ||||||||||||||||||||||||||||