Col.php 824 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * PHP表单生成器
  4. *
  5. * @package FormBuilder
  6. * @author xaboy <xaboy2005@qq.com>
  7. * @version 2.0
  8. * @license MIT
  9. * @link https://github.com/xaboy/form-builder
  10. * @document http://php.form-create.com
  11. */
  12. namespace FormBuilder\Annotation;
  13. use FormBuilder\Contract\AnnotationInterface;
  14. /**
  15. * @Annotation
  16. */
  17. final class Col implements AnnotationInterface
  18. {
  19. public $props = 24;
  20. protected function getCol()
  21. {
  22. if (is_integer($this->props))
  23. return ['span' => $this->props];
  24. else
  25. return $this->props;
  26. }
  27. public function parseRule($rule)
  28. {
  29. $rule['col'] = $this->getCol();
  30. return $rule;
  31. }
  32. public function parseComponent($component)
  33. {
  34. $component->col($this->getCol());
  35. return $component;
  36. }
  37. }