/** * Compare objects for sorting on publication date. * * @return int An integer used for sorting. * @param SpoonFeedRSSItem $object1 The first element. * @param SpoonFeedRSSItem $object2 The second element. */ private static function compareObjects(SpoonFeedRSSItem $object1, SpoonFeedRSSItem $object2) { // if the object have the same publicationdate there are equal if ($object1->getPublicationDate() == $object2->getPublicationDate()) { return 0; } // sort ascending if (self::$sortingMethod == 'asc') { // if the publication date is greater then the other return 1, so we known howto sort if ($object1->getPublicationDate() > $object2->getPublicationDate()) { return 1; } // if the publication date is smaller then the other return -1, so we known howto sort if ($object1->getPublicationDate() < $object2->getPublicationDate()) { return -1; } } else { // if the publication date is greater then the other return -1, so we known howto sort if ($object1->getPublicationDate() > $object2->getPublicationDate()) { return -1; } // if the publication date is smaller then the other return 1, so we known howto sort if ($object1->getPublicationDate() < $object2->getPublicationDate()) { return 1; } } }