Skip to content

Instantly share code, notes, and snippets.

@PoTHuYJoHN
Created May 31, 2017 11:32
Show Gist options
  • Save PoTHuYJoHN/3b1e222b36cd918bd944981d84e93d45 to your computer and use it in GitHub Desktop.
Save PoTHuYJoHN/3b1e222b36cd918bd944981d84e93d45 to your computer and use it in GitHub Desktop.
Trial time with Carbon
<?php
class ServicePackageRepository
{
/**
* @return int
*/
public function getTrialDaysCount()
{
$cDate = Carbon::parse(self::TRIAL_DUE_FOR_STANDARD_PLAN);
return $cDate->diffInDays(Carbon::today()->setTime(17,0,0)) + 1;
}
/**
* @param string $planName
* @return bool
*/
public function canUseTrial(string $planName)
{
return $planName === self::STANDARD_PLAN_NAME
&& Carbon::now()->lt(Carbon::parse(self::TRIAL_DUE_FOR_STANDARD_PLAN));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment