Beispiel #1
0
 function it_can_tell_the_previous_period_even_if_it_is_in_the_previous_year()
 {
     $this->beConstructedWith(Month::fromName('January'), Year::fromNumber(2014));
     $next = $this->previous();
     $next->getMonth()->shouldBeLike(Month::fromNumber(12));
     $next->getYear()->shouldBeLike(Year::fromNumber(2013));
 }
Beispiel #2
0
 public function previous()
 {
     if (1 === $this->month->toNumber()) {
         $month = Month::fromNumber(12);
         $year = $this->year->previous();
     } else {
         $month = $this->month->previous();
         $year = $this->year;
     }
     return new self($month, $year);
 }
Beispiel #3
0
 function it_can_not_be_constructed_with_incorrect_date()
 {
     $this->shouldThrow('InvalidArgumentException')->during('__construct', [32, new Period(Month::fromNumber(4), Year::fromNumber(2013))]);
 }