Conditions | 6 |
Paths | 7 |
Total Lines | 32 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 18 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
24 | 3 | public function execute(ProcessState $state) |
|
25 | { |
||
26 | 3 | $fields = $state->getOptions()['fields']; |
|
27 | 3 | $data = $state->getOptions()['data'] ?: $state->getData(); |
|
28 | |||
29 | 3 | if (!is_array($data)) { |
|
30 | 1 | return; |
|
31 | } |
||
32 | |||
33 | 2 | $collected = ''; |
|
34 | 2 | foreach ($fields as $field) { |
|
35 | 2 | $collected .= '|'.$data[$field]; |
|
36 | } |
||
37 | |||
38 | 2 | if (isset($this->collector[$collected])) { |
|
39 | 2 | if ($state->getOption('throw_error')) { |
|
40 | 1 | throw new NonUniqueException( |
|
41 | 1 | sprintf('skipped, this data is not unique (%s)', $collected) |
|
42 | ); |
||
43 | } |
||
44 | |||
45 | 1 | $state->warning( |
|
46 | 1 | 'skipped, this data is not unique', |
|
47 | 1 | ['collected' => $collected] |
|
48 | ); |
||
49 | |||
50 | 1 | $state->markIgnore(); |
|
51 | |||
52 | 1 | return; |
|
53 | } |
||
54 | |||
55 | 2 | $this->collector[$collected] = 1; |
|
56 | 2 | } |
|
63 |