class
SeasonalProduct
{
protected
$price;
public
function
__construct($price)
{
$this-‐>price
=
$price;
}
public
function
getPrice()
{
$multiplier
=
1;
if
(Carbon::now()-‐>month
==
12)
{
$multiplier
=
2;
}
return
$this-‐>price
*
$multiplier;
}
}
$product
=
new
SeasonalProduct(100);
Carbon::setTestNow(Carbon::parse('first
day
of
March
2000'));
echo
$product-‐>getPrice();
//
100
Carbon::setTestNow(Carbon::parse('first
day
of
December
2000'));
echo
$product-‐>getPrice();
//
200
Carbon::setTestNow(Carbon::parse('first
day
of
May
2000'));
echo
$product-‐>getPrice();
//
100
Carbon::setTestNow();