WalletDepositCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 23
c 0
b 0
f 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 1
A configure() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\ChargeableApi\Bridge\Symfony\Console\Command;
6
7
use Damax\ChargeableApi\Credit;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
use Symfony\Component\Console\Style\SymfonyStyle;
12
13
final class WalletDepositCommand extends WalletCommand
14
{
15
    protected static $defaultName = 'damax:chargeable-api:wallet:deposit';
16
17
    protected function configure()
18
    {
19
        $this
20
            ->setDescription('Deposit credit.')
21
            ->addArgument('identity', InputArgument::REQUIRED, 'Identity.')
22
            ->addArgument('credit', InputArgument::REQUIRED, 'Credit.')
23
        ;
24
    }
25
26
    protected function execute(InputInterface $input, OutputInterface $output)
27
    {
28
        $identity = $this->identityFactory->create();
29
30
        $credit = Credit::fromInteger((int) $input->getArgument('credit'));
31
32
        $wallet = $this->walletFactory->create($identity);
33
        $wallet->deposit($credit);
34
35
        (new SymfonyStyle($input, $output))->success(sprintf('Balance: %d', $wallet->balance()->toInteger()));
36
    }
37
}
38