Source of file CamelcaseToUnderscore.php
Size: 0,977 Bytes - Last Modified: 2015-12-22T09:12:14-05:00
../src/Filter/CamelcaseToUnderscore.php
123456789101112131415161718192021222324252627282930313233
Covered by 3 test(s):
3435
Covered by 3 test(s):
36
Covered by 3 test(s):
37
Covered by 2 test(s):
38
Covered by 2 test(s):
39
Covered by 3 test(s):
40
Covered by 3 test(s):
41
Covered by 3 test(s):
424344
| <?php /** * camelcase to underscore filter * * @category PHP * @package MvcLite * @subpackage Filter * @since File available since release 1.1.x * @author Cory Collier <corycollier@corycollier.com> */ namespace MvcLite\Filter; use MvcLite\FilterAbstract as FilterAbstract; /** * camelcase to underscore filter * * @category PHP * @package MvcLite * @subpackage Filter * @since Class available since release 1.1.x * @author Cory Collier <corycollier@corycollier.com> */ class CamelcaseToUnderscore extends FilterAbstract { /** * (non-PHPdoc) * @see \MvcLite\FilterAbstract::filter() */ public function filter($word = '') { $result = ''; for ($i = 0; $i < strlen($word); $i++) { if ($i > 0 && strtolower($word{$i}) !== $word{$i}) { $result .= '_'; } $result .= strtolower($word{$i}); } return $result; } } |