PropertySortResolver   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
eloc 8
c 0
b 0
f 0
dl 0
loc 11
ccs 0
cts 7
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 9 1
1
<?php
2
3
namespace App\Service;
4
5
use App\Enum\PropertySort;
6
7
class PropertySortResolver
8
{
9
    public function resolve(string $sort): array
10
    {
11
        return match ($sort) {
12
            PropertySort::PUBLISHED_AT_ASC => ['publishedAt', 1],
13
            PropertySort::PRICE_ASC => ['price', 1],
14
            PropertySort::PRICE_DESC => ['price', -1],
15
            PropertySort::AREA_ASC => ['area', 1],
16
            PropertySort::AREA_DESC => ['area', -1],
17
            default => ['publishedAt', -1],
18
        };
19
    }
20
}
21