NotifyCommandInput::getChannelsAsString()   A
last analyzed

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 function __construct(
18
        array $symbols,
19
        int $maxNews,
20 2
        int $maxRepetitions,
21
        int $sleepingTime,
22 2
        string $channelsAsString,
23 2
    ) {
24 2
        $this->symbols = $symbols;
25 2
        $this->maxNews = $maxNews;
26 2
        $this->maxRepetitions = $maxRepetitions;
27
        $this->sleepingTime = $sleepingTime;
28
        $this->channelsAsString = $channelsAsString;
29
    }
30
31 2
    public static function createFromInput(InputInterface $input): self
32
    {
33
        /** @psalm-suppress PossiblyInvalidCast */
34
        $channelsAsString = (string) $input->getOption('channels');
35
36
        return new self(
37
            (array) $input->getArgument('symbols'),
38 2
            (int) $input->getOption('maxNews'),
39 2
            (int) $input->getOption('maxRepetitions'),
40 2
            (int) $input->getOption('sleepingTime'),
41 2
            $channelsAsString,
42 2
        );
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