PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.6
YayMail – WooCommerce Email Customizer v4.4.6
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
yaymail / vendor-prefixed / src / License / PluginInfoFactory.php

PluginInfoFactory.php in YayMail – WooCommerce Email Customizer 4.4.6, at vendor-prefixed/src/License/PluginInfoFactory.php

40 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 YayMailScoped\YayCommerce\AdminShell\License;
4
5 use YayMailScoped\YayCommerce\AdminShell\License\Contracts\LicenseConfigAdapter;
6 use YayMailScoped\YayCommerce\AdminShell\Registry\PluginLicenseInfo;
7 /**
8 * Builds a PluginLicenseInfo data object from a LicenseHandler's current state.
9 */
10 class PluginInfoFactory
11 {
12 public static function from_adapter(LicenseConfigAdapter $adapter): PluginLicenseInfo
13 {
14 $license = new License($adapter);
15 $raw_info = $license->get_license_info();
16 $expires_raw = $raw_info['expires'] ?? null;
17 $activations_used = (int) ($raw_info['site_count'] ?? 0);
18 $activations_limit = (int) ($raw_info['license_limit'] ?? 0);
19 $status = 'inactive';
20 if ($license->is_active()) {
21 $status = $license->is_expired() ? 'expired' : 'valid';
22 }
23 $info = new PluginLicenseInfo();
24 $info->slug = $adapter->get_plugin_slug();
25 $info->name = $adapter->get_plugin_name();
26 $info->version = $adapter->get_plugin_version();
27 $info->basename = $adapter->get_plugin_basename();
28 $info->item_id = $adapter->get_item_id();
29 $info->store_link = $adapter->get_store_link();
30 $info->license_key = (string) $license->get_license_key();
31 $info->status = $status;
32 $info->expires_at = $expires_raw && 'Not updated' !== $expires_raw ? $expires_raw : null;
33 $info->activations_used = $activations_used;
34 $info->activations_limit = $activations_limit;
35 $info->is_legacy = \false;
36 $info->raw_info = $raw_info;
37 return $info;
38 }
39 }
40