-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-element.php
63 lines (49 loc) · 1.32 KB
/
create-element.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
51
52
53
54
55
56
57
58
59
60
61
62
<?php
require_once __DIR__ . "/musicxml.php";
function getDescription($name)
{
return ucfirst(str_replace('-', ' ', $name));
}
function getClassName($name)
{
return str_replace(' ', '', ucwords(str_replace('-', ' ', $name)));
}
function getPropertyName($name)
{
return lcfirst(str_replace(' ', '', ucwords(str_replace('-', ' ', $name))));
}
$elementList = '
<work>
<movement-number>
<movement-title>
<identification>
<defaults>
<credit>[]
<part-list>
<measure>[]
';
$elementList = str_replace(array('<', '>'), '', $elementList);
$elements = explode("\r\n", $elementList);
$props = array();
foreach($elements as $elementFull)
{
$element = str_replace(array('[', ']'), '', $elementFull);
if(!empty($element))
{
$isArray = stripos($elementFull, '[') !== false;
$mark = $isArray ? '[]' : '';
getObject($element);
$className = getClassName($element);
$description = getDescription($element);
$propertyName = getPropertyName($element);
$prop = "\t/**\r\n"
."\t * ".$description."\r\n"
."\t *\r\n"
."\t * @Element(name=\"".$element."\")\r\n"
."\t * @var $className"."$mark\r\n"
."\t */\r\n"
."\tpublic \$".$propertyName.";\r\n\r\n";
$props[] = $prop;
}
}
echo implode("", $props);