ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Alignment.php
Go to the documentation of this file.
1<?php
2
4
6use SimpleXMLElement;
7
8class Alignment extends StyleBase
9{
10 protected const VERTICAL_ALIGNMENT_STYLES = [
11 AlignmentStyles::VERTICAL_BOTTOM,
12 AlignmentStyles::VERTICAL_TOP,
13 AlignmentStyles::VERTICAL_CENTER,
14 AlignmentStyles::VERTICAL_JUSTIFY,
15 ];
16
17 protected const HORIZONTAL_ALIGNMENT_STYLES = [
18 AlignmentStyles::HORIZONTAL_GENERAL,
19 AlignmentStyles::HORIZONTAL_LEFT,
20 AlignmentStyles::HORIZONTAL_RIGHT,
21 AlignmentStyles::HORIZONTAL_CENTER,
22 AlignmentStyles::HORIZONTAL_CENTER_CONTINUOUS,
23 AlignmentStyles::HORIZONTAL_JUSTIFY,
24 ];
25
26 public function parseStyle(SimpleXMLElement $styleAttributes): array
27 {
28 $style = [];
29
30 foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
31 $styleAttributeValue = (string) $styleAttributeValue;
32 switch ($styleAttributeKey) {
33 case 'Vertical':
34 if (self::identifyFixedStyleValue(self::VERTICAL_ALIGNMENT_STYLES, $styleAttributeValue)) {
35 $style['alignment']['vertical'] = $styleAttributeValue;
36 }
37
38 break;
39 case 'Horizontal':
40 if (self::identifyFixedStyleValue(self::HORIZONTAL_ALIGNMENT_STYLES, $styleAttributeValue)) {
41 $style['alignment']['horizontal'] = $styleAttributeValue;
42 }
43
44 break;
45 case 'WrapText':
46 $style['alignment']['wrapText'] = true;
47
48 break;
49 case 'Rotate':
50 $style['alignment']['textRotation'] = $styleAttributeValue;
51
52 break;
53 }
54 }
55
56 return $style;
57 }
58}
An exception for terminatinating execution or to throw for unit testing.
parseStyle(SimpleXMLElement $styleAttributes)
Definition: Alignment.php:26
$style
Definition: example_012.php:70