mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-09 17:41:24 +01:00
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Composer\ValueObject;
|
|
|
|
use Rector\Composer\Contract\VersionAwareInterface;
|
|
use Rector\Composer\Rector\ChangePackageVersionComposerRector;
|
|
use RectorPrefix20211029\Webmozart\Assert\Assert;
|
|
final class ReplacePackageAndVersion implements \Rector\Composer\Contract\VersionAwareInterface
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $oldPackageName;
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $newPackageName;
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $version;
|
|
public function __construct(string $oldPackageName, string $newPackageName, string $version)
|
|
{
|
|
$this->version = $version;
|
|
\RectorPrefix20211029\Webmozart\Assert\Assert::notSame($oldPackageName, $newPackageName, 'Old and new package have to be different. If you want to only change package version, use ' . \Rector\Composer\Rector\ChangePackageVersionComposerRector::class);
|
|
$this->oldPackageName = $oldPackageName;
|
|
$this->newPackageName = $newPackageName;
|
|
}
|
|
public function getOldPackageName() : string
|
|
{
|
|
return $this->oldPackageName;
|
|
}
|
|
public function getNewPackageName() : string
|
|
{
|
|
return $this->newPackageName;
|
|
}
|
|
public function getVersion() : string
|
|
{
|
|
return $this->version;
|
|
}
|
|
}
|