
#                                      Copyright 2024 WebPros International, LLC
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited.

package Whostmgr::360Monitoring::Util::PackagesAndFiles;

use cPstrict;
use Exporter 'import';

our @EXPORT_OK = qw/
  &snake_to_uppercamel
  &concat_packages
  &class_to_dir
  &class_to_file
  /;

our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );

# Resolves INI table names, to paths to config classes.
sub snake_to_uppercamel ($name) {
    $name = lc($name);
    $name =~ s/_(.)/\u$1/g;
    return ucfirst($name);
}

sub concat_packages (@packages) {
    return join '::', @packages;
}

sub class_to_dir ($class) {
    $class =~ s/::/\//g;
    $class = "/usr/local/cpanel/" . $class;
    return $class;
}

sub class_to_file ($class) {
    $class =~ s/::/\//g;
    return "$class.pm";
}

1;

__END__

=head1 NAME

Whostmgr::360Monitoring::Util::PackagesAndFiles

=head2 FUNCTIONS

=over 12

=item snake_to_uppercamel( $name )

The call C<get_role_package('foo_bar')> returns FooBar. Used to resolve INI names to file names.

=item concat_packages( @packages, $short_name )

The call C<concat_packages('Whostmgr::360Monitoring::Agent', 'Plugins', 'Cpanel')> returns L<Whostmgr::360Monitoring::Agent::Cpanel>.


=item class_to_dir( $class )

The call to C<class_to_dir('Foobar::Baz')> returns "Foobar/Baz"

=item class_to_file( $class )

The call to C<class_to_file('Foobar::Baz')> returns "Foobar/Baz.pm"

=back
