Passed
Push — master ( e879f4...f6cdcb )
by Chema
03:02
created

NotifyCommandInput::getChannelsAsString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chemaclass\StockTicker\Infrastructure\Command\ReadModel;
6
7
use Symfony\Component\Console\Input\InputInterface;
8
9
final class NotifyCommandInput
10
{
11
    private array $symbols;
12
    private int $maxNews;
13
    private int $maxRepetitions;
14
    private int $sleepingTime;
15
    private string $channelsAsString;
16
17 2
    public static function createFromInput(InputInterface $input): self
18
    {
19
        /** @psalm-suppress PossiblyInvalidCast */
20 2
        $channelsAsString = (string) $input->getOption('channels');
21
22 2
        return new self(
23 2
            (array) $input->getArgument('symbols'),
24 2
            (int) $input->getOption('maxNews'),
25 2
            (int) $input->getOption('maxRepetitions'),
26 2
            (int) $input->getOption('sleepingTime'),
27
            $channelsAsString
28
        );
29
    }
30
31 2
    public function __construct(
32
        array $symbols,
33
        int $maxNews,
34
        int $maxRepetitions,
35
        int $sleepingTime,
36
        string $channelsAsString
37
    ) {
38 2
        $this->symbols = $symbols;
39 2
        $this->maxNews = $maxNews;
40 2
        $this->maxRepetitions = $maxRepetitions;
41 2
        $this->sleepingTime = $sleepingTime;
42 2
        $this->channelsAsString = $channelsAsString;
43 2
    }
44
45
    /**
46
     * @return string[] $symbols
47
     */
48 2
    public function getSymbols(): array
49
    {
50 2
        return $this->symbols;
51
    }
52
53 2
    public function getMaxNews(): int
54
    {
55 2
        return $this->maxNews;
56
    }
57
58 2
    public function getMaxRepetitions(): int
59
    {
60 2
        return $this->maxRepetitions;
61
    }
62
63 2
    public function getSleepingTime(): int
64
    {
65 2
        return $this->sleepingTime;
66
    }
67
68 2
    public function getChannelsAsString(): string
69
    {
70 2
        return $this->channelsAsString;
71
    }
72
}
73