3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Filter\Word
;
12 use Zend\Stdlib\StringUtils
;
14 class SeparatorToCamelCase
extends AbstractSeparator
17 * Defined by Zend\Filter\Filter
19 * @param string $value
22 public function filter($value)
24 // a unicode safe way of converting characters to \x00\x00 notation
25 $pregQuotedSeparator = preg_quote($this->separator
, '#');
27 if (StringUtils
::hasPcreUnicodeSupport()) {
29 '#(' . $pregQuotedSeparator.')(\p{L}{1})#u',
32 if (!extension_loaded('mbstring')) {
33 $replacements = array(
35 return strtoupper($matches[2]);
38 return strtoupper($matches[1]);
42 $replacements = array(
44 return mb_strtoupper($matches[2], 'UTF-8');
47 return mb_strtoupper($matches[1], 'UTF-8');
53 '#(' . $pregQuotedSeparator.')([A-Za-z]{1})#',
56 $replacements = array(
58 return strtoupper($matches[2]);
61 return strtoupper($matches[1]);
67 foreach ($patterns as $index => $pattern) {
68 $filtered = preg_replace_callback($pattern, $replacements[$index], $filtered);