Skip to content

Commit

Permalink
MyFxBookManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Rick in t Veld committed Sep 5, 2024
1 parent 4a1be91 commit 9932b56
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Command/AccountDataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace App\Command;

use App\ActionHandler\ActionHandlerInterface;
use App\Contract\Repository\MyFxBookRepositoryInterface;
use App\Contract\Repository\UserRepositoryInterface;
use App\Dto\Aggregator\AggregateRoot;
use App\Manager\MyFxBookManager;
use App\Presentation\Output\TableInterface;
use App\Strategy\StrategyManagerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
Expand All @@ -29,7 +29,7 @@ class AccountDataCommand extends Command
* @param StrategyManagerInterface<ActionHandlerInterface> $tableStrategy
*/
public function __construct(
private readonly MyFxBookRepositoryInterface $myFxBookRepository,
private readonly MyFxBookManager $myFxBookManager,
private readonly UserRepositoryInterface $userRepository,
private readonly StrategyManagerInterface $actionHandlerStrategy,
private readonly StrategyManagerInterface $tableStrategy,
Expand All @@ -41,20 +41,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);

/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');

$user = $this->userRepository->findLatest();

if (is_null($user)) {
$io->error('No user found!');
}

$accounts = $this->myFxBookRepository->accounts($user->getSession());
$accountIds = array_map(static fn($a) => $a['id'], $accounts);

$question = new ChoiceQuestion('Select account ID', $accountIds);
$account = $helper->ask($input, $output, $question);
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
$account = $helper->ask($input, $output, new ChoiceQuestion('Select an account ID', $this->myFxBookManager->accountIds($user)));

Check failure on line 52 in src/Command/AccountDataCommand.php

View workflow job for this annotation

GitHub Actions / lint

Parameter #1 $user of method App\Manager\MyFxBookManager::accountIds() expects App\Entity\User, App\Entity\User|null given.
$dataType = $helper->ask($input, $output, new ChoiceQuestion('Please choose a data type: ', self::DATA_TYPES));

$aggregator = new AggregateRoot();
Expand Down
22 changes: 22 additions & 0 deletions src/Manager/MyFxBookManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace App\Manager;

use App\Contract\Repository\MyFxBookRepositoryInterface;
use App\Entity\User;

class MyFxBookManager
{
public function __construct(
private readonly MyFxBookRepositoryInterface $myFxBookRepository
) {}

public function accountIds(User $user): array

Check failure on line 16 in src/Manager/MyFxBookManager.php

View workflow job for this annotation

GitHub Actions / lint

Method App\Manager\MyFxBookManager::accountIds() return type has no value type specified in iterable type array.
{
$accounts = $this->myFxBookRepository->accounts($user->getSession());

Check failure on line 18 in src/Manager/MyFxBookManager.php

View workflow job for this annotation

GitHub Actions / lint

Parameter #1 $session of method App\Contract\Repository\MyFxBookRepositoryInterface::accounts() expects string, string|null given.

return array_map(static fn($a) => $a['id'], $accounts);
}
}

0 comments on commit 9932b56

Please sign in to comment.