for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
*
* @package sitemaker
* @copyright (c) 2013 Daniel A. (blitze)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*/
namespace blitze\content\services\form\field;
class text extends base
{
/** @var int */
protected $maxlength = 0;
* @inheritdoc
public function get_name()
return 'text';
}
public function get_default_props()
return array(
'maxlength' => 255,
'size' => 40,
);
public function get_validation_rules(array $data)
$this->maxlength = $data['field_props']['maxlength'];
'filter' => FILTER_CALLBACK,
'options' => array(
'options' => array($this, 'is_valid'),
),
* @param string $value
* @return false|string
protected function is_valid($value)
if ($this->maxlength && utf8_strlen($value) > $this->maxlength)
utf8_strlen
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
if ($this->maxlength && /** @scrutinizer ignore-call */ utf8_strlen($value) > $this->maxlength)
return false;
return $value;
public function get_error_message(array $data)
return $this->language->lang('FIELD_TOO_LONG', $data['field_label'], $this->maxlength);