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

Asc::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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