Skip to content

Commit

Permalink
Fixes #229, do not set the datetime objects when there is no valid da…
Browse files Browse the repository at this point in the history
…te given.
  • Loading branch information
michael-pay committed Mar 7, 2021
1 parent 0043e43 commit 8a36349
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions lib/Tmdb/Model/Common/Change/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ public function getTime()
}

/**
* @param string|DateTime $time
* @param string|DateTime|null $time
* @return $this
*/
public function setTime($time)
public function setTime($time = null)
{
if (!$time instanceof DateTime) {
if (!$time instanceof DateTime && $time !== null) {
$time = new DateTime($time);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Tmdb/Model/Movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,12 @@ public function getReleaseDate()
}

/**
* @param string $releaseDate
* @param DateTime|string|null $releaseDate
* @return $this
*/
public function setReleaseDate($releaseDate)
public function setReleaseDate($releaseDate = null)
{
if (!$releaseDate instanceof DateTime) {
if (!$releaseDate instanceof DateTime && $releaseDate !== null) {
$releaseDate = new DateTime($releaseDate);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Tmdb/Model/Movie/Release.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ public function getReleaseDate()
}

/**
* @param string|DateTime $releaseDate
* @param string|DateTime|null $releaseDate
* @return $this
*/
public function setReleaseDate($releaseDate)
public function setReleaseDate($releaseDate = null)
{
if (!$releaseDate instanceof DateTime) {
if (!$releaseDate instanceof DateTime && $releaseDate !== null) {
$releaseDate = new DateTime($releaseDate);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Tmdb/Model/Movie/ReleaseDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ public function getReleaseDate()
}

/**
* @param string|DateTime $releaseDate
* @param string|DateTime|null $releaseDate
* @return $this
*/
public function setReleaseDate($releaseDate)
public function setReleaseDate($releaseDate = null)
{
if (!$releaseDate instanceof DateTime) {
if (!$releaseDate instanceof DateTime && $releaseDate !== null) {
$releaseDate = new DateTime($releaseDate);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Tmdb/Model/Person/Credit.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,12 @@ public function getReleaseDate()
}

/**
* @param DateTime $releaseDate
* @param DateTime|string|null $releaseDate
* @return $this
*/
public function setReleaseDate($releaseDate)
public function setReleaseDate($releaseDate = null)
{
if (!$releaseDate instanceof DateTime) {
if (!$releaseDate instanceof DateTime && $releaseDate !== null) {
$releaseDate = new DateTime($releaseDate);
}

Expand Down
12 changes: 6 additions & 6 deletions lib/Tmdb/Model/Tv.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,12 @@ public function getFirstAirDate()
}

/**
* @param DateTime $firstAirDate
* @param DateTime|string|null $firstAirDate
* @return $this
*/
public function setFirstAirDate($firstAirDate)
public function setFirstAirDate($firstAirDate = null)
{
if (!$firstAirDate instanceof DateTime) {
if (!$firstAirDate instanceof DateTime && $firstAirDate !== null) {
$firstAirDate = new DateTime($firstAirDate);
}

Expand Down Expand Up @@ -461,12 +461,12 @@ public function getLastAirDate()
}

/**
* @param string $lastAirDate
* @param DateTime|string|null $lastAirDate
* @return $this
*/
public function setLastAirDate($lastAirDate)
public function setLastAirDate($lastAirDate = null)
{
if (!$lastAirDate instanceof DateTime) {
if (!$lastAirDate instanceof DateTime && $lastAirDate !== null) {
$lastAirDate = new DateTime($lastAirDate);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Tmdb/Model/Tv/Episode.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ public function getAirDate()
}

/**
* @param DateTime $airDate
* @param DateTime|string|null $airDate
* @return $this
*/
public function setAirDate($airDate)
public function setAirDate($airDate = null)
{
if (!$airDate instanceof DateTime) {
if (!$airDate instanceof DateTime && $airDate !== null) {
$airDate = new DateTime($airDate);
}

Expand Down

0 comments on commit 8a36349

Please sign in to comment.