Passed
Push — main ( 189a60...255c0f )
by Yevhenii
02:11
created

URLPaginationEnum   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A paginate() 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 string[]
19
     * @throws InvalidArgumentException
20
     */
21
    public function paginate(int $page = 1, int $count = 10): array
22
    {
23
        return match ($this) {
24
            self::Start => [self::Start->value => $page * $count, self::Count->value => $count],
25
            default => throw new InvalidArgumentException('Unexpected match value'),
26
        };
27
    }
28
}