Clone.php 872 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Dummy AttrDef that mimics another AttrDef, BUT it generates clones
  4. * with make.
  5. */
  6. class HTMLPurifier_AttrDef_Clone extends HTMLPurifier_AttrDef
  7. {
  8. /**
  9. * What we're cloning.
  10. * @type HTMLPurifier_AttrDef
  11. */
  12. protected $clone;
  13. /**
  14. * @param HTMLPurifier_AttrDef $clone
  15. */
  16. public function __construct($clone)
  17. {
  18. $this->clone = $clone;
  19. }
  20. /**
  21. * @param string $v
  22. * @param HTMLPurifier_Config $config
  23. * @param HTMLPurifier_Context $context
  24. * @return bool|string
  25. */
  26. public function validate($v, $config, $context)
  27. {
  28. return $this->clone->validate($v, $config, $context);
  29. }
  30. /**
  31. * @param string $string
  32. * @return HTMLPurifier_AttrDef
  33. */
  34. public function make($string)
  35. {
  36. return clone $this->clone;
  37. }
  38. }
  39. // vim: et sw=4 sts=4