/** * @param string $identifier * @throws NonStringIdentifier */ public function __construct($identifier) { if (!is_string($identifier)) { throw NonStringIdentifier::forNonString($identifier); } if (empty($identifier)) { throw NonStringIdentifier::forEmptyString(); } $this->identifier = (string) $identifier; }
/** * @covers \PhpCqrs\Domain\Identifier\Exception\NonStringIdentifier::forEmptyString */ public function testCanConstructForEmptyString() { $exception = NonStringIdentifier::forEmptyString(); $this->assertInstanceOf(NonStringIdentifier::class, $exception); $this->assertSame('Non string identifier, got empty string.', $exception->getMessage()); }