Skip to content

Commit

Permalink
Update WeidOidConverter.php : Spec Change 12
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmarschall authored Sep 10, 2024
1 parent 761699b commit a9205aa
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions WeidOidConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//
// The full specification can be found here: https://weid.info/spec.html
//
// This converter supports WEID as of Spec Change #11
// This converter supports WEID as of Spec Change #12
//
// A few short notes:
// - There are several classes of WEIDs which have different OID bases:
Expand All @@ -36,6 +36,7 @@
// - The namespace (weid:, weid:pen:, weid:root:) is case insensitive.
// - Padding with '0' characters is valid (e.g. weid:000EXAMPLE-3)
// The paddings do not count into the WeLuhn check digit.
// - URN Notation "urn:x-weid:..." is equal to "weid:..."
//

namespace Frdl\Weid;
Expand Down Expand Up @@ -130,6 +131,8 @@ public static function weid2oid(string &$weid) {
$namespace = substr($weid, 0, $p+1);
$rest = substr($weid, $p+1);

$weid = preg_replace('@^urn:x-weid:@', 'weid:', $weid);

$namespace = strtolower($namespace); // namespace is case insensitive

if (str_starts_with($namespace, 'weid:')) {
Expand All @@ -143,16 +146,16 @@ public static function weid2oid(string &$weid) {
}
}

if (str_starts_with(strtolower($namespace), 'weid:x-')) {
if (str_starts_with($namespace, 'weid:x-')) {
// Spec Change 11: Proprietary Namespaces ( https://github.com/frdl/weid/issues/4 )
return "[Proprietary WEID Namespace]";
} else if (strtolower($namespace) == 'weid:') {
} else if ($namespace == 'weid:') {
// Class C
$base = '1-3-6-1-4-1-SZ5-8';
} else if (strtolower($namespace) == 'weid:pen:') {
} else if ($namespace == 'weid:pen:') {
// Class B
$base = '1-3-6-1-4-1';
} else if (strtolower($namespace) == 'weid:root:') {
} else if ($namespace == 'weid:root:') {
// Class A
$base = '';
} else {
Expand Down

0 comments on commit a9205aa

Please sign in to comment.