PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / app / Services / ShortCodeParser / Parsers / LicenseParser.php

LicenseParser.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at app/Services/ShortCodeParser/Parsers/LicenseParser.php

49 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Services\ShortCodeParser\Parsers;
4
5 use FluentCart\Framework\Support\Arr;
6
7 class LicenseParser extends BaseParser
8 {
9 private $license;
10
11 public function __construct($data)
12 {
13 $this->license = Arr::get($data, 'license');
14 parent::__construct($data);
15 }
16
17 public function parse($accessor = null, $code = null, $transformer = null): ?string
18 {
19 $license = $this->license;
20
21 if (!$license) {
22 return '';
23 }
24
25 switch ($accessor) {
26 case 'sl':
27 return (string) (isset($license->sl) ? $license->sl : '');
28 case 'key':
29 return esc_html($license->license_key);
30 case 'status':
31 return esc_html($license->status);
32 case 'product_name':
33 return esc_html($license->product ? $license->product->post_title : '');
34 case 'variant':
35 return esc_html($license->productVariant ? $license->productVariant->variation_title : '');
36 case 'limit':
37 return $license->limit ? esc_html($license->limit) : __('Unlimited', 'fluent-cart');
38 case 'activation_count':
39 return esc_html($license->activation_count);
40 case 'expiration_date':
41 return $license->expiration_date
42 ? esc_html(date('M j, Y', strtotime($license->expiration_date)))
43 : __('Never', 'fluent-cart');
44 default:
45 return Arr::get((array) $license, $accessor, '');
46 }
47 }
48 }
49