1: <?php
2:
3: namespace webfilesframework\codegeneration\general;
4:
5: 6: 7: 8: 9: 10:
11: abstract class MAbstractClass extends MAbstractCodeItem
12: {
13:
14: protected $className;
15:
16: protected $isAbstract = false;
17: protected $visibility = "public";
18:
19: protected $attributes = array();
20: protected $methods = array();
21:
22:
23: 24: 25: 26: 27: 28: 29:
30: public function __construct($className, $isAbstract = false, $visibility = "public")
31: {
32:
33: $this->className = $className;
34:
35: $this->isAbstract = $isAbstract;
36: $this->visibility = $visibility;
37:
38: }
39:
40:
41: public function generateCode()
42: {
43: $code = $this->generatePreambleCode();
44: $code .= $this->generateHeaderCode();
45:
46:
47: $code .= $this->generateAttributesCode();
48: $code .= $this->generateMethodsCode();
49:
50:
51: $code .= $this->generateFooterCode();
52:
53: return $code;
54: }
55:
56:
57: protected abstract function generatePreambleCode();
58:
59: protected abstract function generateHeaderCode();
60:
61: protected function generateAttributesCode()
62: {
63: $code = "";
64: foreach ($this->attributes as $attribute) {
65: $code .= $attribute->generateCode();
66: }
67: return $code;
68: }
69:
70: protected function generateMethodsCode()
71: {
72: $code = "";
73: foreach ($this->methods as $method) {
74: $code .= $method->generateCode();
75: }
76: return $code;
77: }
78:
79: protected abstract function generateFooterCode();
80: }
81: