@@ -77,18 +77,22 @@ abstract class AbstractContainer extends AbstractElement
77
77
*/
78
78
public function __call ($ function , $ args )
79
79
{
80
- $ elements = array ('Text ' , 'TextRun ' , 'Link ' , 'PreserveText ' , 'TextBreak ' ,
81
- 'ListItem ' , 'ListItemRun ' , 'Table ' , 'Image ' , 'Object ' , 'Footnote ' ,
82
- 'Endnote ' , 'CheckBox ' , 'TextBox ' , 'Field ' , 'Line ' , 'Shape ' ,
83
- 'Title ' , 'TOC ' , 'PageBreak ' , 'Chart ' , 'FormField ' , 'SDT ' );
80
+ $ elements = array (
81
+ 'Text ' , 'TextRun ' , 'Link ' , 'PreserveText ' , 'TextBreak ' ,
82
+ 'ListItem ' , 'ListItemRun ' , 'Table ' , 'Image ' , 'Object ' ,
83
+ 'Footnote ' , 'Endnote ' , 'CheckBox ' , 'TextBox ' , 'Field ' ,
84
+ 'Line ' , 'Shape ' , 'Title ' , 'TOC ' , 'PageBreak ' ,
85
+ 'Chart ' , 'FormField ' , 'SDT '
86
+ );
84
87
$ functions = array ();
85
- for ($ i = 0 ; $ i < count ( $ elements ); $ i ++ ) {
86
- $ functions [$ i ] = 'add ' . $ elements [ $ i ] ;
88
+ foreach ($ elements as $ element ) {
89
+ $ functions ['add ' . strtolower ( $ element )] = $ element ;
87
90
}
88
91
89
92
// Run valid `add` command
90
- if (in_array ($ function , $ functions )) {
91
- $ element = str_replace ('add ' , '' , $ function );
93
+ $ function = strtolower ($ function );
94
+ if (array_key_exists ($ function , $ functions )) {
95
+ $ element = $ functions [$ function ];
92
96
93
97
// Special case for TextBreak
94
98
// @todo Remove the `$count` parameter in 1.0.0 to make this element similiar to other elements?
0 commit comments