| Total Complexity | 15 |
| Total Lines | 126 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | class Key implements SortKey |
||
| 30 | { |
||
| 31 | /** |
||
| 32 | * variable name or macro |
||
| 33 | * @var string |
||
|
1 ignored issue
–
show
|
|||
| 34 | */ |
||
| 35 | private $variable; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * the sort direction can be set to either “ascending” (default) or “descending” with the sort attribute |
||
| 39 | * @var string |
||
|
1 ignored issue
–
show
|
|||
| 40 | */ |
||
| 41 | private $sort = "ascending"; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * macro name |
||
| 45 | * @var string |
||
|
1 ignored issue
–
show
|
|||
| 46 | */ |
||
| 47 | private $macro; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * only relevant for date ranges |
||
| 51 | * @var int |
||
|
1 ignored issue
–
show
|
|||
| 52 | */ |
||
| 53 | private $rangePart = 1; |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Key constructor. |
||
| 57 | * The cs:sort element must contain one or more cs:key child elements. The sort key, set as an attribute on cs:key, |
||
| 58 | * must be a variable (see Appendix IV - Variables) or macro name. For each cs:key element, the sort direction can |
||
| 59 | * be set to either “ascending” (default) or “descending” with the sort attribute. |
||
| 60 | * |
||
| 61 | * TODO: The attributes names-min, names-use-first, and names-use-last may be used to override the values of the |
||
| 62 | * corresponding et-al-min/et-al-subsequent-min, et-al-use-first/et-al-subsequent-use-first and et-al-use-last |
||
| 63 | * attributes, and affect all names generated via macros called by cs:key. |
||
| 64 | * |
||
| 65 | * @param \SimpleXMLElement $node |
||
|
1 ignored issue
–
show
|
|||
| 66 | */ |
||
| 67 | 44 | public function __construct(\SimpleXMLElement $node) |
|
| 68 | { |
||
| 69 | /** @var \SimpleXMLElement $attribute */ |
||
|
3 ignored issues
–
show
|
|||
| 70 | 44 | foreach ($node->attributes() as $attribute) { |
|
| 71 | 44 | $name = $attribute->getName(); |
|
| 72 | 44 | if ($name === "variable") { |
|
| 73 | 29 | $this->variable = (string) $attribute; |
|
| 74 | } |
||
| 75 | 44 | if ($name === "sort") { |
|
| 76 | 21 | $this->sort = (string) $attribute; |
|
| 77 | } |
||
| 78 | 44 | if ($name === "macro") { |
|
| 79 | 29 | $this->variable = "macro"; |
|
| 80 | 29 | $this->macro = (string) $attribute; |
|
| 81 | } |
||
| 82 | } |
||
| 83 | 44 | } |
|
| 84 | |||
| 85 | /** |
||
|
1 ignored issue
–
show
|
|||
| 86 | * @return string |
||
| 87 | */ |
||
| 88 | 27 | public function getVariable() |
|
| 89 | { |
||
| 90 | 27 | return $this->variable; |
|
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
|
1 ignored issue
–
show
|
|||
| 94 | * @return string (ascending|descending) |
||
| 95 | */ |
||
| 96 | 27 | public function getSort() |
|
| 97 | { |
||
| 98 | 27 | return $this->sort; |
|
| 99 | } |
||
| 100 | |||
| 101 | /** |
||
|
1 ignored issue
–
show
|
|||
| 102 | * @return string |
||
| 103 | */ |
||
| 104 | 13 | public function getMacro() |
|
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
|
1 ignored issue
–
show
|
|||
| 110 | * @return bool |
||
| 111 | */ |
||
| 112 | 27 | public function isNameVariable() |
|
| 115 | } |
||
| 116 | |||
| 117 | /** |
||
|
1 ignored issue
–
show
|
|||
| 118 | * @return bool |
||
| 119 | */ |
||
| 120 | 26 | public function isNumberVariable() |
|
| 121 | { |
||
| 122 | 26 | return Variables::isNumberVariable($this->variable); |
|
| 123 | } |
||
| 124 | |||
| 125 | /** |
||
|
1 ignored issue
–
show
|
|||
| 126 | * @return bool |
||
| 127 | */ |
||
| 128 | 27 | public function isDateVariable() |
|
| 131 | } |
||
| 132 | |||
| 133 | /** |
||
|
1 ignored issue
–
show
|
|||
| 134 | * @return bool |
||
| 135 | */ |
||
| 136 | 21 | public function isMacro() |
|
| 139 | } |
||
| 140 | |||
| 141 | /** |
||
|
1 ignored issue
–
show
|
|||
| 142 | * @param $rangePart |
||
| 143 | */ |
||
| 144 | 1 | public function setRangePart($rangePart) |
|
| 147 | 1 | } |
|
| 148 | |||
| 149 | /** |
||
|
1 ignored issue
–
show
|
|||
| 150 | * @return int |
||
| 151 | */ |
||
| 152 | 5 | public function getRangePart() |
|
| 155 | } |
||
| 156 | } |