for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Stu\Component\Ship\Refactor;
use Stu\Component\Ship\System\ShipSystemTypeEnum;
use Stu\Module\Ship\Lib\ShipWrapperFactoryInterface;
use Stu\Orm\Repository\ShipRepositoryInterface;
final class RefactorWarpdriveSplitRunner
{
private ShipRepositoryInterface $shipRepository;
private ShipWrapperFactoryInterface $shipWrapperFactory;
public function __construct(
ShipRepositoryInterface $shipRepository,
ShipWrapperFactoryInterface $shipWrapperFactory
) {
$this->shipRepository = $shipRepository;
$this->shipWrapperFactory = $shipWrapperFactory;
}
public function refactor(): void
foreach ($this->shipRepository->findAll() as $ship) {
if (!$ship->hasShipSystem(ShipSystemTypeEnum::SYSTEM_WARPCORE)) {
continue;
$wrapper = $this->shipWrapperFactory->wrapShip($ship);
$warpcore = $wrapper->getWarpCoreSystemData();
$warpdrive = $wrapper->getWarpDriveSystemData();
if ($warpcore === null || $warpdrive === null) {
$warpdrive->setWarpCoreSplit($warpcore->getWarpCoreSplit())
Stu\Component\Ship\Syste...ata::getWarpCoreSplit()
If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated annotation
ignore-deprecated
$warpdrive->setWarpCoreSplit(/** @scrutinizer ignore-deprecated */ $warpcore->getWarpCoreSplit())
->update();