Skip to content

Commit

Permalink
Changed addition methods to return a new self
Browse files Browse the repository at this point in the history
  • Loading branch information
StaffCollab committed May 1, 2024
1 parent 02bdaf0 commit 1fea7b2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/HebrewDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function addHebrewMonths(int $month = 1): self
$month--;
}

return $this;
return self::createFromJewishDate($this->jewishYear, $this->jewishMonth, $this->jewishDay);
}

public function subHebrewMonths(int $month = 1): self
Expand All @@ -30,44 +30,44 @@ public function subHebrewMonths(int $month = 1): self
$month--;
}

return $this;
return self::createFromJewishDate($this->jewishYear, $this->jewishMonth, $this->jewishDay);
}

public function addHebrewYears(int $year = 1): self
{
$this->jewishYear += $year;
return $this;
return self::createFromJewishDate($this->jewishYear, $this->jewishMonth, $this->jewishDay);
}

public function subHebrewYears(int $year = 1): self
{
$this->jewishYear -= $year;
return $this;
return self::createFromJewishDate($this->jewishYear, $this->jewishMonth, $this->jewishDay);
}

public function startOfHebrewMonth(): self
{
$this->jewishDay = 1;
return $this;
return self::createFromJewishDate($this->jewishYear, $this->jewishMonth, $this->jewishDay);
}

public function endOfHebrewMonth(): self
{
$this->startOfHebrewMonth()->addHebrewMonths()->subDay();
return $this;
return self::createFromJewishDate($this->jewishYear, $this->jewishMonth, $this->jewishDay);
}

public function startOfHebrewYear(): self
{
$this->jewishMonth = 1;
$this->jewishDay = 1;
return $this;
return self::createFromJewishDate($this->jewishYear, $this->jewishMonth, $this->jewishDay);
}

public function endOfHebrewYear(): self
{
$this->startOfHebrewYear()->addHebrewYears()->subDay();
return $this;
return self::createFromJewishDate($this->jewishYear, $this->jewishMonth, $this->jewishDay);
}

public function getDaysPeriod(): Collection
Expand Down

0 comments on commit 1fea7b2

Please sign in to comment.