Source of file UnderscoreToCamelcase.php

Size: 0,979 Bytes - Last Modified: 2015-12-22T09:42:40-05:00

../src/Filter/UnderscoreToCamelcase.php

123456789101112131415161718192021222324252627282930313233
Covered by 5 test(s):
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #4
3435
Covered by 5 test(s):
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #4
36
Covered by 5 test(s):
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #4
37
Covered by 5 test(s):
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #4
38
Covered by 5 test(s):
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #4
3940
Covered by 5 test(s):
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #4
41
Covered by 5 test(s):
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #4
4243
Covered by 5 test(s):
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #0
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #1
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #2
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #3
  • MvcLite\FilterUnderscoreToCamelcaseTest::testFilter with data set #4
444546
<?php
/**
 * string to upper 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;

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

        foreach ($words as $i => $word) {
            if (! $i) {
                $words[$i] = strtolower($word);
                continue;
            }
            $words[$i] = ucwords($word);
        }

        return implode('', $words);
    }
}