Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   1  <?php
   2  
   3  namespace Box\Spout\Writer\Common\Creator\Style;
   4  
   5  use Box\Spout\Common\Entity\Style\Border;
   6  use Box\Spout\Common\Entity\Style\BorderPart;
   7  use Box\Spout\Common\Entity\Style\Color;
   8  
   9  /**
  10   * Class BorderBuilder
  11   */
  12  class BorderBuilder
  13  {
  14      /**
  15       * @var Border
  16       */
  17      protected $border;
  18  
  19      public function __construct()
  20      {
  21          $this->border = new Border();
  22      }
  23  
  24      /**
  25       * @param string $color Border A RGB color code
  26       * @param string $width Border width @see BorderPart::allowedWidths
  27       * @param string $style Border style @see BorderPart::allowedStyles
  28       * @return BorderBuilder
  29       */
  30      public function setBorderTop($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
  31      {
  32          $this->border->addPart(new BorderPart(Border::TOP, $color, $width, $style));
  33  
  34          return $this;
  35      }
  36  
  37      /**
  38       * @param string $color Border A RGB color code
  39       * @param string $width Border width @see BorderPart::allowedWidths
  40       * @param string $style Border style @see BorderPart::allowedStyles
  41       * @return BorderBuilder
  42       */
  43      public function setBorderRight($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
  44      {
  45          $this->border->addPart(new BorderPart(Border::RIGHT, $color, $width, $style));
  46  
  47          return $this;
  48      }
  49  
  50      /**
  51       * @param string $color Border A RGB color code
  52       * @param string $width Border width @see BorderPart::allowedWidths
  53       * @param string $style Border style @see BorderPart::allowedStyles
  54       * @return BorderBuilder
  55       */
  56      public function setBorderBottom($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
  57      {
  58          $this->border->addPart(new BorderPart(Border::BOTTOM, $color, $width, $style));
  59  
  60          return $this;
  61      }
  62  
  63      /**
  64       * @param string $color Border A RGB color code
  65       * @param string $width Border width @see BorderPart::allowedWidths
  66       * @param string $style Border style @see BorderPart::allowedStyles
  67       * @return BorderBuilder
  68       */
  69      public function setBorderLeft($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
  70      {
  71          $this->border->addPart(new BorderPart(Border::LEFT, $color, $width, $style));
  72  
  73          return $this;
  74      }
  75  
  76      /**
  77       * @return Border
  78       */
  79      public function build()
  80      {
  81          return $this->border;
  82      }
  83  }