-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildClass.php
77 lines (62 loc) · 1.28 KB
/
BuildClass.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
include("PHPGrammer.php");
class BuildClass
{
/*
* PHP grammer.
*/
private $grammer;
/*
* Path where our class will be built.
*/
public $save_path;
public function __construct()
{
$this->grammer = new PHPGrammer();
}
public function __get($name) {
if (property_exists($this->grammer , $name)) {
return $this->grammer->$name;
} else {
echo "no property = ". $name;
}
}
private function BuildStaticClass()
{
if ($this->is_static) {
return "static ";
}
}
private function BuildExtendsClass()
{
if (!!$this->extends_class) {
return "extends ". $this->extends_class;
}
}
private function BuildVars()
{
$string = null;
foreach($this->vars as $var => $var_access_mod) {
$string .= "\n\t" .$var_access_mod . " $".$var."; \n";
}
return $string;
}
public function GeneratePHPFile()
{
// The weird formating is so the newly built class is properly formated.
$PHP = $this->PHP_open_tags."
".$this->BuildStaticClass()."class ".$this->class_name." " .$this->BuildExtendsClass()."
{
".$this->BuildVars()."
public function __construct()
{
}
}
";
return $PHP;
}
public function SaveFile()
{
file_put_contents($this->class_name .'.php', $this->GeneratePHPFile());
}
}