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
;
14 class StringToUpper
extends AbstractUnicode
19 protected $options = array(
26 * @param string|array|Traversable $encodingOrOptions OPTIONAL
28 public function __construct($encodingOrOptions = null)
30 if ($encodingOrOptions !== null) {
31 if (!static::isOptions($encodingOrOptions)) {
32 $this->setEncoding($encodingOrOptions);
34 $this->setOptions($encodingOrOptions);
40 * Defined by Zend\Filter\FilterInterface
42 * Returns the string $value, converting characters to uppercase as necessary
44 * If the value provided is non-scalar, the value will remain unfiltered
45 * and an E_USER_WARNING will be raised indicating it's unfilterable.
47 * @param string $value
48 * @return string|mixed
50 public function filter($value)
52 if (null === $value) {
56 if (!is_scalar($value)) {
59 '%s expects parameter to be scalar, "%s" given; cannot filter',
61 (is_object($value) ?
get_class($value) : gettype($value))
68 if ($this->options
['encoding'] !== null) {
69 return mb_strtoupper((string) $value, $this->options
['encoding']);
72 return strtoupper((string) $value);