PropertySortResolver::resolve()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 9
ccs 0
cts 7
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
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