From 4bf4af8741ca723273ae9aff0f1d6c38511e2a07 Mon Sep 17 00:00:00 2001 From: Alessandro Cosentino Date: Tue, 8 May 2012 15:57:08 -0400 Subject: rudimental item class and tests on it --- lib/item.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 lib/item.php (limited to 'lib/item.php') diff --git a/lib/item.php b/lib/item.php new file mode 100644 index 000000000..6a18ded1c --- /dev/null +++ b/lib/item.php @@ -0,0 +1,57 @@ +. +* +*/ + + +class StatusFlag{ + const Unread = 0x02; + const Important = 0x04; + const Deleted = 0x08; + const Updated = 0x16; +} + +/* +* This class models an item +* +* It wraps a SimplePie item and adds a status flag to it +*/ +class OC_News_Item{ + + private $spitem; //the SimplePie item + private $status; //a bit-field set with status flags + + public function __construct($spitem){ + $this->spitem = $spitem; + $this->status |= StatusFlag::Unread; + } + + public function setRead(){ + $this->status |= ~StatusFlag::Unread; + } + + public function setUnread(){ + $this->status |= StatusFlag::Unread; + } + + public function isRead(){ + return ($this->status & ~StatusFlag::Unread); + } +} -- cgit v1.2.3