Completed
Push — master ( af5658...fe61ae )
by Thomas
06:08
created

AbstractPackageGenerator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 6
dl 0
loc 30
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getTemplateFolder() 0 3 1
A generate() 0 7 1
A generateClass() 0 10 1
ensureBasicSetup() 0 1 ?
addMethods() 0 1 ?
1
<?php
2
namespace keeko\tools\generator\package;
3
4
use keeko\tools\generator\AbstractCodeGenerator;
5
use gossi\codegen\model\PhpClass;
6
use keeko\framework\schema\KeekoPackageSchema;
7
use gossi\docblock\tags\LicenseTag;
8
9
abstract class AbstractPackageGenerator extends AbstractCodeGenerator {
10
	
11
	protected function getTemplateFolder() {
12
		return 'package';
13
	}
14
	
15
	public function generate(KeekoPackageSchema $pkg) {
16
		$class = $this->generateClass($pkg);
17
		$class = $this->loadClass($class);
18
		
19
		$this->ensureBasicSetup($class);
20
		$this->addMethods($class);
21
	}
22
	
23
	protected function generateClass(KeekoPackageSchema $pkg) {
24
		$class = PhpClass::create($pkg->getClass());
25
		$class->setDescription($pkg->getTitle());
26
			
27
		$docblock = $class->getDocblock();
28
		$docblock->appendTag(new LicenseTag($this->package->getLicense()));
0 ignored issues
show
Bug introduced by
The property package does not seem to exist. Did you mean packageService?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
29
		$this->codegenService->addAuthors($class, $this->package);
0 ignored issues
show
Bug introduced by
The property package does not seem to exist. Did you mean packageService?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
30
		
31
		return $class;
32
	}
33
	
34
	abstract protected function ensureBasicSetup(PhpClass $class);
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
35
	
36
	abstract protected function addMethods(PhpClass $class);
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
37
38
}