DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

Behaviour

To know what a behaviour is, read the chapter “Behaviours”.

Behaviour example: lower case

<?php
namespace Romm\Formz\Behaviours;

/**
 * Transforms a value in lowercase.
 *
 * @see \Romm\Formz\Behaviours\AbstractBehaviour
 */
class ToLowerCaseBehaviour extends AbstractBehaviour {
    /**
     * @inheritdoc
     */
    public function applyBehaviour($value)
    {
        if (is_array($value)) {
            foreach ($value as $key => $val) {
                $value[$key] = $this->applyBehaviour($val);
            }
        }
        else {
            $value = $this->applyBehaviourInternal($value);
        }

        return $value;
    }

    /**
     * Transforms the given value in lower case.
     *
     * @param  mixed    $value    The value.
     * @return string
     */
    protected function applyBehaviourInternal($value)
    {
        return mb_strtolower($value, 'UTF-8');
    }
}