for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the Version package.
*
* Copyright (c) Nikola Posa <[email protected]>
* For full copyright and license information, please refer to the LICENSE file,
* located at the package root folder.
*/
namespace Version\Identifier;
use Version\Exception\InvalidIdentifierValueException;
* @author Nikola Posa <[email protected]>
abstract class BaseIdentifier implements Identifier
{
* @var string
private $value;
private function __construct($value)
$this->value = $value;
}
* @param string $value
* @return static
* @throws InvalidIdentifierValueException
public static function create($value)
if (!is_string($value)) {
throw new InvalidIdentifierValueException('Identifier value must be of type string');
if ($value === '') {
throw new InvalidIdentifierValueException('Identifier must not be empty');
static::validate($value);
return new static($value);
protected static function validate($value)
public function getValue()
return $this->value;
public function __toString()
return $this->getValue();