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

NotifyCommandInput   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 23
c 1
b 0
f 0
dl 0
loc 62
ccs 24
cts 24
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getMaxRepetitions() 0 3 1
A createFromInput() 0 11 1
A __construct() 0 12 1
A getSleepingTime() 0 3 1
A getMaxNews() 0 3 1
A getSymbols() 0 3 1
A getChannelsAsString() 0 3 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