Completed
Push — master ( fa66ff...b613b3 )
by Peter
10:20
created

ParentChildTrashHandler   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A setupHandlers() 0 10 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: peter
5
 * Date: 08.02.18
6
 * Time: 10:28
7
 */
8
9
namespace Maslosoft\Mangan\Events\Handlers;
10
11
12
use Maslosoft\Addendum\Utilities\ClassChecker;
13
use Maslosoft\Mangan\Helpers\ParentChildTrashHandlers;
14
use Maslosoft\Mangan\Interfaces\EventHandlersInterface;
15
16
class ParentChildTrashHandler implements EventHandlersInterface
17
{
18
	public $parentClass = '';
19
20
	public $childClass = '';
21
22
	/**
23
	 * This method will be called only once, and should setup event handlers.
24
	 */
25
	public function setupHandlers()
26
	{
27
		assert(!empty($this->parentClass));
28
		assert(!empty($this->childClass));
29
		assert(ClassChecker::exists($this->parentClass));
30
		assert(ClassChecker::exists($this->childClass));
31
		$handler = new ParentChildTrashHandlers;
32
		$handler->registerParent($this->parentClass, $this->childClass);
33
		$handler->registerChild($this->childClass, $this->parentClass);
34
	}
35
}