public function validate(array $data) { parent::validate($data); foreach ($data as $value) { if (!is_numeric($value)) { throw new \InvalidArgumentException('Cannot add non-numeric value to NumberSet'); } } }
public function testUnion() { $foo = new Set(['red', 'green', 'blue']); $bar = new Set(['red', 'green']); $diff = $foo->withUnion($bar); $this->assertSame(['red', 'green', 'blue'], $diff->toArray()); $diff = $bar->withUnion($foo); $this->assertSame(['red', 'green', 'blue'], $diff->toArray()); }