create() публичный статический Метод

public static create ( UniqueValue $value, integer $limit ) : UniqueValueGenerationLimitReachedException
$value Nelmio\Alice\Definition\Value\UniqueValue
$limit integer
Результат UniqueValueGenerationLimitReachedException
 public function testTestCreateNewExceptionWithFactory()
 {
     $exception = UniqueValueGenerationLimitReachedExceptionFactory::create(new UniqueValue('unique_id', new \stdClass()), 10);
     $this->assertEquals('Could not generate a unique value after 10 attempts for "unique_id".', $exception->getMessage());
     $this->assertEquals(0, $exception->getCode());
     $this->assertNull($exception->getPrevious());
 }
Пример #2
0
 private function incrementCounter(int $tryCounter, UniqueValue $value, int $limit) : int
 {
     ++$tryCounter;
     if ($tryCounter > $limit) {
         throw UniqueValueGenerationLimitReachedExceptionFactory::create($value, $limit);
     }
     return $tryCounter;
 }