mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-08-03 23:21:44 +00:00
Merge 5fa167b944 into 86fcafe47d
This commit is contained in:
commit
d2d3b9c4dc
2 changed files with 17 additions and 0 deletions
|
|
@ -94,6 +94,13 @@ readonly class ParameterDTO
|
|||
|
||||
//If both parts have the same unit and both values are numerical, we'll save it as range
|
||||
if ($unit === $unit2 && is_numeric($number) && is_numeric($number2)) {
|
||||
//If the parameter contains AWG in name or unit and min/max order is "wrong", swap it
|
||||
if (preg_match('/AWG/', $name . $unit) === 1 && $number > $number2) {
|
||||
$tmp = $number;
|
||||
$number = $number2;
|
||||
$number2 = $tmp;
|
||||
}
|
||||
|
||||
return new self(name: $name, value_text: $value_text2, value_min: (float) $number,
|
||||
value_max: (float) $number2, unit: $unit, symbol: $symbol, group: $group);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,16 @@ final class ParameterDTOTest extends TestCase
|
|||
'test'
|
||||
];
|
||||
|
||||
//Test inverse AWG range
|
||||
yield [
|
||||
new ParameterDTO('test', value_min: 14, value_max: 22, unit: 'AWG', symbol: 'm', group: 'test'),
|
||||
'test',
|
||||
'22..14',
|
||||
'AWG',
|
||||
'm',
|
||||
'test'
|
||||
];
|
||||
|
||||
//Test ranges with tilde
|
||||
yield [
|
||||
new ParameterDTO('test', value_min: -1.0, value_max: 2.0, unit: 'kg', symbol: 'm', group: 'test'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue