4 * Represents a Length as defined by CSS.
6 class HTMLPurifier_AttrDef_CSS_Length extends HTMLPurifier_AttrDef
10 * @type HTMLPurifier_Length|string
15 * @type HTMLPurifier_Length|string
20 * @param HTMLPurifier_Length|string $min Minimum length, or null for no bound. String is also acceptable.
21 * @param HTMLPurifier_Length|string $max Maximum length, or null for no bound. String is also acceptable.
23 public function __construct($min = null, $max = null)
25 $this->min = $min !== null ? HTMLPurifier_Length::make($min) : null;
26 $this->max = $max !== null ? HTMLPurifier_Length::make($max) : null;
30 * @param string $string
31 * @param HTMLPurifier_Config $config
32 * @param HTMLPurifier_Context $context
35 public function validate($string, $config, $context)
37 $string = $this->parseCDATA($string);
43 if ($string === '0') {
46 if (strlen($string) === 1) {
50 $length = HTMLPurifier_Length::make($string);
51 if (!$length->isValid()) {
56 $c = $length->compareTo($this->min);
65 $c = $length->compareTo($this->max);
73 return $length->toString();