Source of file CamelcaseToDash.php
Size: 0,958 Bytes - Last Modified: 2015-12-22T09:12:14-05:00
../src/Filter/CamelcaseToDash.php
123456789101112131415161718192021222324252627282930313233
Covered by 3 test(s):
34
Covered by 3 test(s):
35
Covered by 3 test(s):
36
Covered by 2 test(s):
37
Covered by 2 test(s):
38
Covered by 3 test(s):
39
Covered by 3 test(s):
40
Covered by 3 test(s):
414243
| <?php /** * camelcase to dash 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 dash filter * * @category PHP * @package MvcLite * @subpackage Filter * @since Class available since release 1.1.x * @author Cory Collier <corycollier@corycollier.com> */ class CamelcaseToDash 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; } } |