TableCollection   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 24
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A add() 0 9 4
1
<?php
2
3
namespace Zortje\MySQLKeeper\Database;
4
5
use Zortje\MySQLKeeper\Common\Collection;
6
7
/**
8
 * Class TableCollection
9
 *
10
 * @package Zortje\MySQLKeeper\Database
11
 */
12
class TableCollection extends Collection {
13
14
	/**
15
	 * @var Table[] Database tabel
16
	 */
17
	protected $collection = [];
18
19
	/**
20
	 * Add table to collection
21
	 *
22
	 * @param Table $table
23
	 *
24
	 * @throws \InvalidArgumentException if incorrect object type is added
25
	 */
26 2
	public function add($table) {
27 2
		if (!is_object($table) || get_class($table) !== 'Zortje\MySQLKeeper\Database\Table') {
28 1
			$argumentType = is_object($table) ? get_class($table) : gettype($table);
29
30 1
			throw new \InvalidArgumentException(sprintf('Collection may only contain "%s" objects, "%s" is not allowed', 'Zortje\MySQLKeeper\Database\Table', $argumentType));
31
		}
32
33 1
		$this->collection[] = $table;
34 1
	}
35
}
36