Clone.php 872 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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