PluginProbe
seQura / 3.0.0
seQura v3.0.0
4.3.4 4.3.3 4.3.2 4.3.1 trunk 2.0.0 2.0.10 2.0.11 2.0.12 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0.0 3.0.2 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 4.0.0 All 30 releases
sequra / src / Dto / class-payment-method-data.php

class-payment-method-data.php in seQura 3.0.0, at src/Dto/class-payment-method-data.php

65 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Payment Method Data DTO
4 *
5 * @package SeQura/WC
6 */
7
8 namespace SeQura\WC\Dto;
9
10 /**
11 * Payment Method Data DTO.
12 */
13 class Payment_Method_Data extends Dto {
14
15 /**
16 * SeQura product
17 *
18 * @var string
19 */
20 public $product;
21
22 /**
23 * Campaign
24 *
25 * @var string
26 */
27 public $campaign;
28
29 /**
30 * SeQura product title
31 *
32 * @var string
33 */
34 public $title;
35
36 /**
37 * Encode the DTO instance into a raw string. Returns a base64 encoded JSON string.
38 */
39 public function encode(): string {
40 $encoded = parent::encode();
41 $encoded = base64_encode( $encoded );
42 return $encoded ? $encoded : '';
43 }
44
45 /**
46 * Decode a raw string into a DTO instance. Assumes that the raw string is a base64 encoded JSON string.
47 *
48 * @return static|null
49 */
50 public static function decode( string $raw ): mixed {
51 $decoded = base64_decode( $raw );
52 if ( ! $decoded ) {
53 return null;
54 }
55 return parent::decode( $decoded );
56 }
57
58 /**
59 * Check if the instance contains valid data.
60 */
61 public function is_valid(): bool {
62 return ! empty( $this->product );
63 }
64 }
65