package Orchard::NameCase;

use strict;
use warnings;

sub camel {
	my $self = shift;
	my $text = shift;
	$text =~ s/_/ /g;
	## taken from Lingua::EN::NameCase
	$text =~ s{ \b (\w)   }{\u$1}gox;
	$text =~ s/ //g;
	$text;
}

sub underscore {
	my $self = shift;
	my $text = shift;
	$text = lc($text);
	$text =~ s/  */_/g;
	$text;
}

sub camel_to_underscore {
	my $self = shift;
	my $text = shift;
	$text =~ s/^([A-Z])/lc($1)/e;
	$text =~ s/([A-Z])/'_' . lc($1)/eg;
	$text;
}

sub lcamel {
	my $self = shift;
	my $text = shift;
	$text = lcfirst( $self->camel($text) );
	$text;
}

sub underscore_to_camel {
	my $self = shift;
	my $text = shift;
	$self->camel($text);
}

1;
