PluginProbe ʕ •ᴥ•ʔ
WP Chat App / trunk
WP Chat App vtrunk
3.8.1 3.8.2 trunk 2.6 3.4 3.4.1 3.4.2 3.4.4 3.4.5 3.4.6 3.5 3.6 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0
wp-whatsapp / vendor-prefixed / src / License / PluginInfoFactory.php
wp-whatsapp / vendor-prefixed / src / License Last commit date
Contracts 4 months ago EDD_SL_Plugin_Updater.php 4 months ago License.php 4 months ago LicenseAPI.php 4 months ago LicenseHandler.php 3 months ago PluginInfoFactory.php 4 months ago RestAPI.php 4 months ago
PluginInfoFactory.php
41 lines
1 <?php
2
3 namespace WhatsappScoped\YayCommerce\AdminShell\License;
4
5 use WhatsappScoped\YayCommerce\AdminShell\License\Contracts\LicenseConfigAdapter;
6 use WhatsappScoped\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