Files
piratepoet/lib/Util/Installation.php
Jan Jakeš 0e964de6d4 Move nesbot/carbon to vendor-prefixed
[MAILPOET-2560]
2019-12-15 21:55:48 +00:00

33 lines
851 B
PHP

<?php
namespace MailPoet\Util;
use MailPoet\Settings\SettingsController;
use MailPoet\WP\Functions as WPFunctions;
use MailPoetVendor\Carbon\Carbon;
class Installation {
const NEW_INSTALLATION_DAYS_LIMIT = 30;
/** @var SettingsController */
private $settings;
/** @var WPFunctions */
private $wp;
function __construct(SettingsController $settings, WPFunctions $wp) {
$this->settings = $settings;
$this->wp = $wp;
}
function isNewInstallation() {
$installed_at = $this->settings->get('installed_at');
if (is_null($installed_at)) {
return true;
}
$installed_at = Carbon::createFromTimestamp(strtotime($installed_at));
$current_time = Carbon::createFromTimestamp($this->wp->currentTime('timestamp'));
return $current_time->diffInDays($installed_at) <= self::NEW_INSTALLATION_DAYS_LIMIT;
}
}