Passed
Push — main ( 255c0f...66f102 )
by Yevhenii
02:14
created

URLPaginationEnum   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
eloc 6
c 2
b 0
f 0
dl 0
loc 16
ccs 0
cts 4
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A calculate() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SteamMarketProviders\ParserManager\Enum;
6
7
use SteamMarketProviders\ParserManager\Contract\PaginationInterface;
8
use SteamMarketProviders\ParserManager\Exception\InvalidArgumentException;
9
10
enum URLPaginationEnum: string implements PaginationInterface
11
{
12
    case Start = 'start';
13
    case Count = 'count';
14
15
    /**
16
     * @param int $page
17
     * @param int $count
18
     * @return int
19
     * @throws InvalidArgumentException
20
     */
21
    public function calculate(int $page = 1, int $count = 10): int
22
    {
23
        return match ($this) {
24
            self::Start => $page * $count,
25
            default => throw new InvalidArgumentException('Unexpected match value'),
26
        };
27
    }
28
}
29