Skip to content

Commit 49f51ed

Browse files
authored
Merge pull request #675 from DannyvdSluijs/Deprecate-duplicate-units-class
Deprecate duplicate units class
2 parents caeb3d7 + aa22857 commit 49f51ed

File tree

2 files changed

+19
-28
lines changed

2 files changed

+19
-28
lines changed

src/Picqer/Financials/Exact/Units.php

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,18 @@
22

33
namespace Picqer\Financials\Exact;
44

5+
trigger_error(
6+
sprintf(
7+
'"%s" is deprecated due to an invalid naming convention, use "%s" instead',
8+
Units::class,
9+
Unit::class
10+
),
11+
E_USER_DEPRECATED
12+
);
13+
514
/**
6-
* Class Units.
7-
*
8-
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=LogisticsUnits
9-
*
10-
* @property string $ID Primary key
11-
* @property bool $Active Indicates whether a unit is in use
12-
* @property string $Code Unique code for the unit
13-
* @property string $Description Description
14-
* @property int $Division Division code
15-
* @property int $Main Indicates the main unit per division. Will be used when creating new item
16-
* @property string $TimeUnit If Type = 'T' (time) then this fields indicates the type of time frame. yy = Year, mm = Month, wk = Week, dd = Day, hh = Hour, mi = Minute, ss = Second
17-
* @property string $Type Type 'Time' is especially important for contracts.
15+
* @deprecated since 4.5.0, use \Picqer\Financials\Exact\Unit instead, to be removed in 5.0
1816
*/
19-
class Units extends Model
17+
class Units extends Unit
2018
{
21-
use Query\Findable;
22-
23-
protected $fillable = [
24-
'ID',
25-
'Active',
26-
'Code',
27-
'Description',
28-
'Division',
29-
'Main',
30-
'TimeUnit',
31-
'Type',
32-
];
33-
34-
protected $url = 'logistics/Units';
3519
}

tests/EntityTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public function entityDataProvider(): \Generator
3636
'ApiException.php',
3737
'Model.php',
3838
];
39+
$deprecated = [
40+
'Units.php',
41+
];
3942

4043
while ($iterator->valid()) {
4144
/** @var \SplFileInfo $file */
@@ -45,9 +48,13 @@ public function entityDataProvider(): \Generator
4548
$iterator->next();
4649
continue;
4750
}
51+
if (in_array($file->getFilename(), $deprecated, true)) {
52+
$iterator->next();
53+
continue;
54+
}
4855

4956
$className = substr($file->getFilename(), 0, -4);
50-
yield ["{$namespace}\\{$className}"];
57+
yield $className => ["{$namespace}\\{$className}"];
5158
$iterator->next();
5259
}
5360
}

0 commit comments

Comments
 (0)