diff options
author | Derek Allard <derek.allard@ellislab.com> | 2007-04-15 19:41:17 +0200 |
---|---|---|
committer | Derek Allard <derek.allard@ellislab.com> | 2007-04-15 19:41:17 +0200 |
commit | d2df9bc7cc9d4b3e53818470c5d0977c9a36677c (patch) | |
tree | 23c0794fefaa6860ec997813fefb9c64fcee1983 /system/helpers/inflector_helper.php | |
parent | 9613e2c136c96fbb1d055b36a0a5055811f03451 (diff) |
update pMachine to EllisLab
update copyright year
update Code Igniter to CodeIgniter
Diffstat (limited to 'system/helpers/inflector_helper.php')
-rw-r--r-- | system/helpers/inflector_helper.php | 278 |
1 files changed, 139 insertions, 139 deletions
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index 666ec40b8..fbe851f3b 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -1,140 +1,140 @@ -<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); -/** - * Code Igniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author Rick Ellis - * @copyright Copyright (c) 2006, pMachine, Inc. - * @license http://www.codeignitor.com/user_guide/license.html - * @link http://www.codeigniter.com - * @since Version 1.0 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/** - * Code Igniter Inflector Helpers - * - * @package CodeIgniter - * @subpackage Helpers - * @category Helpers - * @author Rick Ellis - * @link http://www.codeigniter.com/user_guide/helpers/directory_helper.html - */ - - -// -------------------------------------------------------------------- - -/** - * Singular - * - * Takes a singular word and makes it plural - * - * @access public - * @param string - * @return str - */ -function singular($str) -{ - $str = strtolower(trim($str)); - $end = substr($str, -3); - - if ($end == 'ies') - { - $str = substr($str, 0, strlen($str)-3).'y'; - } - else - { - $end = substr($str, -1); - - if ($end == 's') - { - $str = substr($str, 0, strlen($str)-1); - } - } - - return $str; -} - -// -------------------------------------------------------------------- - -/** - * Plural - * - * Takes a plural word and makes it singular - * - * @access public - * @param string - * @return str - */ -function plural($str) -{ - $str = strtolower(trim($str)); - $end = substr($str, -1); - - if ($end == 'y') - { - $str = substr($str, 0, strlen($str)-1).'ies'; - } - elseif ($end != 's') - { - $str .= 's'; - } - - return $str; -} - -// -------------------------------------------------------------------- - -/** - * Camelize - * - * Takes multiple words separated by spaces or underscores and camelizes them - * - * @access public - * @param string - * @return str - */ -function camelize($str) -{ - $str = 'x'.strtolower(trim($str)); - $str = ucwords(preg_replace('/[\s_]+/', ' ', $str)); - return substr(str_replace(' ', '', $str), 1); -} - -// -------------------------------------------------------------------- - -/** - * Underscore - * - * Takes multiple words separated by spaces and underscores them - * - * @access public - * @param string - * @return str - */ -function underscore($str) -{ - return preg_replace('/[\s]+/', '_', strtolower(trim($str))); -} - -// -------------------------------------------------------------------- - -/** - * Humanize - * - * Takes multiple words separated by underscores and changes them to spaces - * - * @access public - * @param string - * @return str - */ -function humanize($str) -{ - return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str)))); -} - +<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Inflector Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/directory_helper.html
+ */
+
+
+// --------------------------------------------------------------------
+
+/**
+ * Singular
+ *
+ * Takes a singular word and makes it plural
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function singular($str)
+{
+ $str = strtolower(trim($str));
+ $end = substr($str, -3);
+
+ if ($end == 'ies')
+ {
+ $str = substr($str, 0, strlen($str)-3).'y';
+ }
+ else
+ {
+ $end = substr($str, -1);
+
+ if ($end == 's')
+ {
+ $str = substr($str, 0, strlen($str)-1);
+ }
+ }
+
+ return $str;
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Plural
+ *
+ * Takes a plural word and makes it singular
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function plural($str)
+{
+ $str = strtolower(trim($str));
+ $end = substr($str, -1);
+
+ if ($end == 'y')
+ {
+ $str = substr($str, 0, strlen($str)-1).'ies';
+ }
+ elseif ($end != 's')
+ {
+ $str .= 's';
+ }
+
+ return $str;
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Camelize
+ *
+ * Takes multiple words separated by spaces or underscores and camelizes them
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function camelize($str)
+{
+ $str = 'x'.strtolower(trim($str));
+ $str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
+ return substr(str_replace(' ', '', $str), 1);
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Underscore
+ *
+ * Takes multiple words separated by spaces and underscores them
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function underscore($str)
+{
+ return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Humanize
+ *
+ * Takes multiple words separated by underscores and changes them to spaces
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function humanize($str)
+{
+ return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
+}
+
?>
\ No newline at end of file |