Skip to content

Commit

Permalink
III-1820: Allow unsetting age-from
Browse files Browse the repository at this point in the history
  • Loading branch information
bramcordie committed Jan 27, 2017
1 parent 0311e93 commit 1845075
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/CultureFeed/Cdb/Item/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CultureFeed_Cdb_Item_Event extends CultureFeed_Cdb_Item_Base implements Cu
{
/**
* Minimum age for the event.
* @var int
* @var int|null
*/
protected $ageFrom;

Expand Down Expand Up @@ -304,6 +304,8 @@ public function setValidator($value)

/**
* Get the minimum age for this event.
*
* @return int|null
*/
public function getAgeFrom()
{
Expand All @@ -313,15 +315,14 @@ public function getAgeFrom()
/**
* Set the minimum age for this event.
*
* @param int $age
* @param int|null $age
* Minimum age.
*
* @throws UnexpectedValueException
*/
public function setAgeFrom($age)
public function setAgeFrom($age = null)
{

if (!is_numeric($age)) {
if (!is_numeric($age) && !is_null($age)) {
throw new UnexpectedValueException('Invalid age: ' . $age);
}

Expand Down Expand Up @@ -499,7 +500,7 @@ public function appendToDOM(DOMElement $element, $cdbScheme = '3.2')
$this->appendKeywordsToDOM($eventElement, $cdbScheme);
$this->appendCategoriesToDOM($eventElement, $cdbScheme);

if ($this->ageFrom) {
if (isset($this->ageFrom)) {
$eventElement->appendChild(
$dom->createElement('agefrom', $this->ageFrom)
);
Expand Down

0 comments on commit 1845075

Please sign in to comment.