Passed
Push — master ( b1f105...c36d1c )
by Claudio
02:11
created

Asc   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sort() 0 7 2
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Budgegeria\IntlSort\Sorter;
6
7
use Budgegeria\IntlSort\Exception\IntlSortException;
8
use Collator;
9
10
final class Asc implements Sorter
11
{
12
    /**
13
     * @var Collator
14
     */
15
    private $collator;
16
17
    /**
18
     * @var int A Collator::SORT_* sort flag
19
     */
20
    private $sortType;
21
22 2
    public function __construct(Collator $collator, int $sortType)
23
    {
24 2
        $this->collator = $collator;
25 2
        $this->sortType = $sortType;
26 2
    }
27
28
    /**
29
     * {@inheritDoc}
30
     */
31 2
    public function sort(array $values) : array
32
    {
33 2
        if (! $this->collator->asort($values, $this->sortType)) {
34 1
            throw IntlSortException::errorOnSort();
35
        }
36
37 1
        return $values;
38
    }
39
}