Source of file ClassToCamelcase.php

Size: 1,025 Bytes - Last Modified: 2015-12-22T09:12:14-05:00

../src/Filter/ClassToCamelcase.php

123456789101112131415161718192021222324252627282930313233
Covered by 7 test(s):
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #4
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #5
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #6
34
Covered by 7 test(s):
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #4
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #5
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #6
3536
Covered by 7 test(s):
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #4
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #5
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #6
3738
Covered by 7 test(s):
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #4
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #5
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #6
39
Covered by 7 test(s):
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #4
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #5
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #6
40
Covered by 7 test(s):
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #4
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #5
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #6
41
Covered by 7 test(s):
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #4
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #5
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #6
4243
Covered by 7 test(s):
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #4
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #5
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #6
44
Covered by 7 test(s):
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #4
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #5
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #6
45
Covered by 7 test(s):
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #4
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #5
  • MvcLite\FilterClassToCamelcaseTest::testFilter with data set #6
464748
<?php
/**
 * class to camelcase 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;

/**
 * class to camelcase filter
 *
 * @category    PHP
 * @package     MvcLite
 * @subpackage  Filter
 * @since       Class available since release 1.1.x
 * @author      Cory Collier <corycollier@corycollier.com>
 */
class ClassToCamelcase extends FilterAbstract
{
    /**
     * (non-PHPdoc)
     * @see \MvcLite\FilterAbstract::filter()
     */
    public function filter($word = '')
    {
        $words = explode('_', $word);
        $word = end($words);

        $result = '';

        for ($i = 0; $i < strlen($word); $i++) {
            if ($i === 0) {
                $result .= strtolower($word{$i});
                continue;
            }
            $result .= $word{$i};
        }
        return $result;
    }
}