summaryrefslogtreecommitdiffstats
path: root/lib/Utility
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-08-29 23:39:35 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2020-09-27 15:35:31 +0200
commitd00d1ab2a28f428223e52b17052c072c64784016 (patch)
treec019f85fb7ac67147dd43ca64b4ac3cda99832f7 /lib/Utility
parent5687baca75d47dbdffd3de74e865ad2f71ef0cb7 (diff)
Create V2 mapper, Service and management commands
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/Utility')
-rw-r--r--lib/Utility/OPMLExporter.php15
-rw-r--r--lib/Utility/Time.php4
-rw-r--r--lib/Utility/Updater.php67
3 files changed, 11 insertions, 75 deletions
diff --git a/lib/Utility/OPMLExporter.php b/lib/Utility/OPMLExporter.php
index 189cf8d1e..8c21fa204 100644
--- a/lib/Utility/OPMLExporter.php
+++ b/lib/Utility/OPMLExporter.php
@@ -13,6 +13,8 @@
namespace OCA\News\Utility;
+use \DOMDocument;
+use \DOMElement;
use OCA\News\Db\Feed;
/**
@@ -26,11 +28,11 @@ class OPMLExporter
*
* @param \OCA\News\Db\Folder[] $folders
* @param \OCA\News\Db\Feed[] $feeds
- * @return \DomDocument the document
+ * @return DOMDocument the document
*/
- public function build($folders, $feeds)
+ public function build(array $folders, array $feeds)
{
- $document = new \DomDocument('1.0', 'UTF-8');
+ $document = new DOMDocument('1.0', 'UTF-8');
$document->formatOutput = true;
$root = $document->createElement('opml');
@@ -81,10 +83,10 @@ class OPMLExporter
/**
* @param Feed $feed
- * @param \DOMDocument $document
- * @return \DOMElement
+ * @param DOMDocument $document
+ * @return DOMElement
*/
- protected function createFeedOutline($feed, $document)
+ protected function createFeedOutline(Feed $feed, DOMDocument $document)
{
$feedOutline = $document->createElement('outline');
$feedOutline->setAttribute('title', $feed->getTitle());
@@ -92,6 +94,7 @@ class OPMLExporter
$feedOutline->setAttribute('type', 'rss');
$feedOutline->setAttribute('xmlUrl', $feed->getUrl());
$feedOutline->setAttribute('htmlUrl', $feed->getLink());
+
return $feedOutline;
}
}
diff --git a/lib/Utility/Time.php b/lib/Utility/Time.php
index 739204f6d..aee1e6358 100644
--- a/lib/Utility/Time.php
+++ b/lib/Utility/Time.php
@@ -13,7 +13,7 @@ namespace OCA\News\Utility;
class Time
{
- public function getTime()
+ public function getTime(): int
{
return time();
}
@@ -21,7 +21,7 @@ class Time
/**
* @return int the current unix time in miliseconds
*/
- public function getMicroTime()
+ public function getMicroTime(): int
{
list($millisecs, $secs) = explode(" ", microtime());
return $secs . substr($millisecs, 2, 6);
diff --git a/lib/Utility/Updater.php b/lib/Utility/Updater.php
deleted file mode 100644
index 01e07291b..000000000
--- a/lib/Utility/Updater.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-/**
- * Nextcloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Alessandro Cosentino <cosenal@gmail.com>
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright 2012 Alessandro Cosentino
- * @copyright 2012-2014 Bernhard Posselt
- */
-
-
-namespace OCA\News\Utility;
-
-use \OCA\News\Service\FolderService;
-use \OCA\News\Service\FeedService;
-use \OCA\News\Service\ItemService;
-
-class Updater
-{
-
- /**
- * @var FolderService
- */
- private $folderService;
-
- /**
- * @var FeedService
- */
- private $feedService;
-
- /**
- * @var ItemService
- */
- private $itemService;
-
- public function __construct(
- FolderService $folderService,
- FeedService $feedService,
- ItemService $itemService
- ) {
- $this->folderService = $folderService;
- $this->feedService = $feedService;
- $this->itemService = $itemService;
- }
-
-
- public function beforeUpdate()
- {
- $this->folderService->purgeDeleted();
- $this->feedService->purgeDeleted();
- }
-
-
- public function update()
- {
- $this->feedService->updateAll();
- }
-
-
- public function afterUpdate()
- {
- $this->itemService->autoPurgeOld();
- }
-}