Final Class Yiisoft\YiiDevTool\Infrastructure\Version
| Inheritance | Yiisoft\YiiDevTool\Infrastructure\Version |
|---|---|
| Implements | Stringable |
Public Methods
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| TYPES | [ self::TYPE_PATCH, self::TYPE_MINOR, self::TYPE_MAJOR, ] | Yiisoft\YiiDevTool\Infrastructure\Version | |
| TYPE_MAJOR | 'Major - Incompatible API changes.' | Yiisoft\YiiDevTool\Infrastructure\Version | |
| TYPE_MINOR | 'Minor - Add functionality (backwards-compatible).' | Yiisoft\YiiDevTool\Infrastructure\Version | |
| TYPE_PATCH | 'Patch - Bug fixes (backwards-compatible).' | Yiisoft\YiiDevTool\Infrastructure\Version |
Method Details
| public mixed __construct ( string $version ) | ||
| $version | string | |
public function __construct(private string $version)
{
}
| public self getNext ( string $type ) | ||
| $type | string | |
public function getNext(string $type): self
{
if ($this->version === '') {
return new self('1.0.0');
}
$parts = explode('.', $this->version);
switch ($type) {
case self::TYPE_MAJOR:
$parts[0]++;
$parts[1] = 0;
$parts[2] = 0;
break;
case self::TYPE_MINOR:
$parts[1]++;
$parts[2] = 0;
break;
case self::TYPE_PATCH:
$parts[2]++;
break;
default:
throw new \RuntimeException('Unknown version type.');
}
return new self(implode('.', $parts));
}
Signup or Login in order to comment.