public function add(Table &$table = null) { if ($this->Some(function ($t) use($table) { return $t->getName() === $table->getName(); })) { throw new \DomainException('Table name must be unique in this collection'); } return parent::Add($table); }
public function testUnique() { $set = new Set(); $set->add('hello', 'world', 'hello', 'hello', '!', 'world'); $expected = 'helloworld!'; $this->assertEquals($expected, $set->unique()->join('')); $set = new Set(array(array(1, 2, 3), array(3), array(3, 5, 5), array(1), array(1, 2))); $newSet = $set->unique(function ($a, $b) { return \count($a) === \count($b); }); $this->assertCount(3, $newSet); }
public function addType(Type $t) { return parent::Add($t); }