<?php

declare(strict_types=1);

namespace External\PompoBundle\Resources\script;

use External\PompoBundle\DataGo\Util\PhotoUpdater;
use KupShop\AdminBundle\Util\Script\Script;
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;

class UpdatePhotosScript extends Script
{
    protected static $name = '[pompo] Update photos';
    protected static $defaultParameters = [
        'hours' => 24,
    ];

    protected function run(array $arguments)
    {
        if (empty($arguments['hours'])) {
            $this->log('Parameter "hours" is required!');

            return;
        }

        $photoUpdater = ServiceContainer::getService(PhotoUpdater::class);
        $photoUpdater->updatePhotosByChanges($arguments['hours']);

        $this->log('Photos updated');
    }
}

return UpdatePhotosScript::class;
