PluginProbe
PostNL for WooCommerce / 4.4.1
PostNL for WooCommerce v4.4.1
5.9.12 5.9.11 5.9.10 5.9.9 5.9.8 5.9.7 5.9.6 trunk 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.1.4 3.1.5 3.1.6 3.1.7 4.0.0 4.0.1 4.0.2 4.3.2 4.3.3 4.4.0 4.4.1 All 72 releases
woo-postnl / vendor / myparcelnl / sdk / src / Helper / TrackTraceUrl.php

TrackTraceUrl.php in PostNL for WooCommerce 4.4.1, at vendor/myparcelnl/sdk/src/Helper/TrackTraceUrl.php

35 lines 903 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 namespace MyParcelNL\Sdk\src\Helper;
4
5 class TrackTraceUrl
6 {
7 const CONSUMER_PORTAL_BASE_URL = "https://myparcel.me/track-trace/";
8
9 /**
10 * Creates a Track & Trace URL to myparcel.me from given barcode, postalCode and optional countryCode. Trims
11 * spaces from postal code and only adds country code to the url if it's added.
12 *
13 * @param string $barcode
14 * @param string $postalCode
15 * @param string|null $countryCode
16 *
17 * @return string
18 */
19 public static function create(
20 string $barcode,
21 string $postalCode,
22 ?string $countryCode = null
23 ): string {
24 $postalCode = str_replace(' ', '', $postalCode);
25
26 $url = self::CONSUMER_PORTAL_BASE_URL . "$barcode/$postalCode";
27
28 if ($countryCode) {
29 $url .= "/$countryCode";
30 }
31
32 return $url;
33 }
34 }
35