Skip to content

Commit

Permalink
Ensure SimplePie::get_item() doesn't fall-through
Browse files Browse the repository at this point in the history
  • Loading branch information
rmccue committed Dec 2, 2012
1 parent 0bec668 commit 7777ef3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions library/SimplePie.php
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,31 @@ public function get_encoding()
return $this->sanitize->output_encoding;
}

/**
* Get a single item from the feed
*
* This is better suited for {@link http://php.net/for for()} loops, whereas
* {@see get_items()} is better suited for
* {@link http://php.net/foreach foreach()} loops.
*
* @see get_item_quantity()
* @since Beta 2
* @param int $key The item that you want to return. Remember that arrays begin with 0, not 1
* @return SimplePie_Item|null
*/
public function get_item($key = 0)
{
$items = $this->get_items();
if (isset($items[$key]))
{
return $items[$key];
}
else
{
return null;
}
}

/**
* Get all items from the feed
*
Expand Down

0 comments on commit 7777ef3

Please sign in to comment.