| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Description of PurchaseCodeInfoRepository |
| 5 |
* |
| 6 |
* @author Ali2Woo Team |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace AliNext_Lite;; |
| 10 |
|
| 11 |
class PurchaseCodeInfoRepository |
| 12 |
{ |
| 13 |
const OPTION_PURCHASE_CODE_INFO = 'a2wl_purchase_code_info'; |
| 14 |
protected PurchaseCodeInfoFactory $PurchaseCodeInfoFactory; |
| 15 |
|
| 16 |
public function __construct(PurchaseCodeInfoFactory $PurchaseCodeInfoFactory) |
| 17 |
{ |
| 18 |
$this->PurchaseCodeInfoFactory = $PurchaseCodeInfoFactory; |
| 19 |
} |
| 20 |
|
| 21 |
public function get(): PurchaseCodeInfo |
| 22 |
{ |
| 23 |
$meta = $this->getAsArray(); |
| 24 |
|
| 25 |
return $this->PurchaseCodeInfoFactory->buildFromData($meta); |
| 26 |
} |
| 27 |
|
| 28 |
public function save(PurchaseCodeInfo $PurchaseCodeInfo): void |
| 29 |
{ |
| 30 |
update_option(self::OPTION_PURCHASE_CODE_INFO, $PurchaseCodeInfo->toArray(), 'no'); |
| 31 |
} |
| 32 |
|
| 33 |
private function getAsArray(): array |
| 34 |
{ |
| 35 |
return get_option(self::OPTION_PURCHASE_CODE_INFO, []); |
| 36 |
} |
| 37 |
} |
| 38 |
|