1: <?php
2:
3: namespace webfilesframework\codegeneration;
4:
5: use webfilesframework\codegeneration\php\MPhpClassAttribute;
6: use webfilesframework\codegeneration\php\MPhpWebfileClass;
7: use webfilesframework\MWebfilesFrameworkException;
8:
9: 10: 11: 12: 13: 14:
15: class MCodeItemFactory
16: {
17:
18: 19: 20: 21: 22: 23:
24: public static function createClass($programmingLanguage, $className)
25: {
26:
27: if ($programmingLanguage == MProgrammingLanguage::PHP) {
28: return new MPhpWebfileClass($className);
29: } else if ($programmingLanguage == MProgrammingLanguage::JAVA) {
30: return new MJavaWebfileClass($className);
31: } else {
32: throw new MWebfilesFrameworkException("Unknown programming language: " . $programmingLanguage);
33: }
34: }
35:
36: 37: 38: 39: 40: 41: 42: 43: 44:
45: public static function createClassAttribute($programmingLanguage, $visibility, $name, $type)
46: {
47: if ($programmingLanguage == MProgrammingLanguage::PHP) {
48: return new MPhpClassAttribute($visibility, $name, $type);
49: } else if ($programmingLanguage == MProgrammingLanguage::JAVA) {
50: return new MJavaClassAttribute($visibility, $name, $type);
51: } else {
52: throw new MWebfilesFrameworkException("Unknown programming language: " . $programmingLanguage);
53: }
54: }
55:
56: }