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