public function add(UniqueValue $value) { $valueId = $value->getId(); if (false === array_key_exists($valueId, $this->pool)) { $this->pool[$valueId] = []; } $this->pool[$valueId][] = $value->getValue(); }
public function testImmutableFactories() { $id = 'Nelmio\\Entity\\User#user0#username'; $value = new \stdClass(); $newValue = new \stdClass(); $newValue->foo = 'bar'; $original = new UniqueValue($id, $value); $clone = $original->withValue($newValue); $this->assertInstanceOf(UniqueValue::class, $clone); $this->assertEquals($id, $original->getId()); $this->assertEquals($id, $clone->getId()); $this->assertEquals($value, $original->getValue()); $this->assertEquals($newValue, $clone->getValue()); }
public static function create(UniqueValue $value, int $limit) : UniqueValueGenerationLimitReachedException { return new UniqueValueGenerationLimitReachedException(sprintf('Could not generate a unique value after %d attempts for "%s".', $limit, $value->getId())); }