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

ModulePackageGenerator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A ensureBasicSetup() 0 4 1
A addMethods() 0 19 4
1
<?php
2
namespace keeko\tools\generator\package;
3
4
use keeko\tools\generator\package\AbstractPackageGenerator;
5
use gossi\codegen\model\PhpClass;
6
use gossi\codegen\model\PhpMethod;
7
use gossi\codegen\model\PhpParameter;
8
9
class ModulePackageGenerator extends AbstractPackageGenerator {
10
	
11
	protected function ensureBasicSetup(PhpClass $class) {
12
		$class->setParentClassName('AbstractModule');
13
		$class->addUseStatement('keeko\\framework\\foundation\\AbstractModule');
14
	}
15
	
16
	protected function addMethods(PhpClass $class) {
17
		// method: install()
18
		if (!$class->hasMethod('install')) {
19
			$class->setMethod(PhpMethod::create('install'));
20
		}
21
		
22
		// method: uninstall()
23
		if (!$class->hasMethod('uninstall')) {
24
			$class->setMethod(PhpMethod::create('uninstall'));
25
		}
26
		
27
		// method: update($from, $to)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
28
		if (!$class->hasMethod('update')) {
29
			$class->setMethod(PhpMethod::create('update')
30
				->addParameter(PhpParameter::create('from')->setType('mixed'))
31
				->addParameter(PhpParameter::create('to')->setType('mixed'))
32
			);
33
		}
34
	}
35
	
36
}