key = $key; $this->name = $name; $this->icon = $icon; $this->tracking_url_template = $tracking_url_template; } /** * Get the key of the shipping provider. * * @return string */ public function get_key(): string { return $this->key; } /** * Get the name of the shipping provider. * * @return string */ public function get_name(): string { return $this->name; } /** * Get the icon URL of the shipping provider. * * @return string */ public function get_icon(): string { return $this->icon; } /** * Get the tracking URL for a given tracking number. * * Replaces __PLACEHOLDER__ in the template with the actual tracking number. * * @param string $tracking_number The tracking number. * @return string The tracking URL with the placeholder replaced. */ public function get_tracking_url( string $tracking_number ): string { if ( empty( $this->tracking_url_template ) ) { return ''; } return str_replace( '__PLACEHOLDER__', rawurlencode( $tracking_number ), $this->tracking_url_template ); } /** * Custom providers do not support automatic tracking number parsing. * * @param string $tracking_number The tracking number. * @param string $shipping_from The country code from which the shipment is sent. * @param string $shipping_to The country code to which the shipment is sent. * @return array|null Always returns null for custom providers. * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ public function try_parse_tracking_number( string $tracking_number, string $shipping_from, string $shipping_to ): ?array { return null; } }