More work

This commit is contained in:
2024-12-10 00:27:24 +04:00
parent d89cc832cb
commit f30f0f1adb
10 changed files with 339 additions and 8 deletions
-2
View File
@@ -87,8 +87,6 @@ class Pf2eGenerateCommand extends Command
$io->writeln("");
}
$io->success('You have a new command! Now make it your own! Pass --help to see your options.');
return Command::SUCCESS;
}
+57
View File
@@ -0,0 +1,57 @@
<?php
namespace App\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[AsCommand(
name: 'pf2e:import',
description: 'Add a short description for your command',
)]
class Pf2eImportCommand extends Command
{
public function __construct()
{
parent::__construct();
}
protected function configure(): void
{
$this
->addOption("revision", null, InputOption::VALUE_REQUIRED, "Load index of specific revision. Default value - latest revision.")
->addOption('type', null, InputOption::VALUE_REQUIRED, 'Specify types to import schema')
->addOption('all', null, InputOption::VALUE_NONE, 'Generate schema for all types')
;
}
private int $revision;
/**
* @var string[]
*/
private array $types;
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$arg1 = $input->getArgument('arg1');
if ($arg1) {
$io->note(sprintf('You passed an argument: %s', $arg1));
}
if ($input->getOption('option1')) {
// ...
}
$io->success('You have a new command! Now make it your own! Pass --help to see your options.');
return Command::SUCCESS;
}
}
@@ -33,7 +33,6 @@ class Schema
}
}
public static function resolveType(mixed $value): string
{
$type = gettype($value);
@@ -28,12 +28,17 @@ class SchemaItem
$this->type = Schema::mergeTypes($this->type, $type);
if (str_contains($this->type, "[]") && !is_null($this->elements)) {
foreach ($value as $element) {
if (!in_array($element, $this->elements)) {
$this->elements[] = $element;
if (!!is_null($this->elements)) {
if (str_contains($this->type, "[]")) {
foreach ($value as $element) {
if (!in_array($element, $this->elements)) {
$this->elements[] = $element;
}
}
}
else if (!in_array($value, $this->elements)) {
$this->elements[] = $value;
}
if (count($this->elements) > 20) {
$this->elements = null;
@@ -64,5 +69,4 @@ class SchemaItem
return $rows;
}
}