PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.2
YayMail – WooCommerce Email Customizer v4.4.2
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.2, at vendor-prefixed/src/License/PluginInfoFactory.php

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