Blame view

vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Style/CellAlignment.php 1.42 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  <?php
  
  namespace PhpOffice\PhpSpreadsheet\Reader\Xls\Style;
  
  use PhpOffice\PhpSpreadsheet\Style\Alignment;
  
  class CellAlignment
  {
      /**
       * @var array<int, string>
       */
      protected static $horizontalAlignmentMap = [
          0 => Alignment::HORIZONTAL_GENERAL,
          1 => Alignment::HORIZONTAL_LEFT,
          2 => Alignment::HORIZONTAL_CENTER,
          3 => Alignment::HORIZONTAL_RIGHT,
          4 => Alignment::HORIZONTAL_FILL,
          5 => Alignment::HORIZONTAL_JUSTIFY,
          6 => Alignment::HORIZONTAL_CENTER_CONTINUOUS,
      ];
  
      /**
       * @var array<int, string>
       */
      protected static $verticalAlignmentMap = [
          0 => Alignment::VERTICAL_TOP,
          1 => Alignment::VERTICAL_CENTER,
          2 => Alignment::VERTICAL_BOTTOM,
          3 => Alignment::VERTICAL_JUSTIFY,
      ];
  
      public static function horizontal(Alignment $alignment, int $horizontal): void
      {
          if (array_key_exists($horizontal, self::$horizontalAlignmentMap)) {
              $alignment->setHorizontal(self::$horizontalAlignmentMap[$horizontal]);
          }
      }
  
      public static function vertical(Alignment $alignment, int $vertical): void
      {
          if (array_key_exists($vertical, self::$verticalAlignmentMap)) {
              $alignment->setVertical(self::$verticalAlignmentMap[$vertical]);
          }
      }
  
      public static function wrap(Alignment $alignment, int $wrap): void
      {
          $alignment->setWrapText((bool) $wrap);
      }
  }