summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSean Molenaar <sean@m2mobi.com>2018-11-29 20:59:46 +0100
committerSean Molenaar <sean@m2mobi.com>2018-12-14 07:54:43 +0100
commitbecce6b7520912257c3d72697a3aefec9923a467 (patch)
treea2e0da34df11ade7c630e9b681fac6d3b2383918 /lib
parent0f2645145ac31ad77788954c513f391bc4fbb295 (diff)
Define an official codestyle and adhere to it.
Diffstat (limited to 'lib')
-rw-r--r--lib/AppInfo/Application.php5
-rw-r--r--lib/Command/Updater/AfterUpdate.php7
-rw-r--r--lib/Command/Updater/AllFeeds.php8
-rw-r--r--lib/Command/Updater/BeforeUpdate.php7
-rw-r--r--lib/Command/Updater/UpdateFeed.php8
-rw-r--r--lib/Config/Config.php52
-rw-r--r--lib/Config/DependencyException.php4
-rw-r--r--lib/Controller/AdminController.php76
-rw-r--r--lib/Controller/ApiController.php10
-rw-r--r--lib/Controller/EntityApiSerializer.php20
-rw-r--r--lib/Controller/ExportController.php13
-rw-r--r--lib/Controller/FeedApiController.php48
-rw-r--r--lib/Controller/FeedController.php73
-rw-r--r--lib/Controller/FolderApiController.php30
-rw-r--r--lib/Controller/FolderController.php50
-rw-r--r--lib/Controller/ItemApiController.php80
-rw-r--r--lib/Controller/ItemController.php82
-rw-r--r--lib/Controller/JSONHttpError.php7
-rw-r--r--lib/Controller/PageController.php61
-rw-r--r--lib/Controller/UserApiController.php6
-rw-r--r--lib/Controller/UtilityApiController.php14
-rw-r--r--lib/Cron/Updater.php9
-rw-r--r--lib/Db/EntityJSONSerializer.php8
-rw-r--r--lib/Db/Feed.php1
-rw-r--r--lib/Db/FeedMapper.php15
-rw-r--r--lib/Db/FeedType.php3
-rw-r--r--lib/Db/Folder.php1
-rw-r--r--lib/Db/FolderMapper.php12
-rw-r--r--lib/Db/Item.php4
-rw-r--r--lib/Db/ItemMapper.php85
-rw-r--r--lib/Db/MapperFactory.php16
-rw-r--r--lib/Db/Mysql/ItemMapper.php9
-rw-r--r--lib/Db/NewsMapper.php17
-rw-r--r--lib/DependencyInjection/IFactory.php1
-rw-r--r--lib/Explore/RecommendedSites.php6
-rw-r--r--lib/Fetcher/FeedFetcher.php190
-rw-r--r--lib/Fetcher/Fetcher.php53
-rw-r--r--lib/Fetcher/FetcherException.php3
-rw-r--r--lib/Fetcher/IFeedFetcher.php46
-rw-r--r--lib/Fetcher/YoutubeFetcher.php52
-rw-r--r--lib/Hooks/User.php3
-rw-r--r--lib/Http/TextDownloadResponse.php3
-rw-r--r--lib/Http/TextResponse.php4
-rw-r--r--lib/Migration/MigrateStatusFlags.php12
-rw-r--r--lib/Plugin/Client/Plugin.php11
-rw-r--r--lib/PostProcessor/LWNProcessor.php19
-rw-r--r--lib/Service/FeedService.php86
-rw-r--r--lib/Service/FolderService.php23
-rw-r--r--lib/Service/ItemService.php122
-rw-r--r--lib/Service/Service.php6
-rw-r--r--lib/Service/ServiceConflictException.php4
-rw-r--r--lib/Service/ServiceException.php4
-rw-r--r--lib/Service/ServiceNotFoundException.php4
-rw-r--r--lib/Service/ServiceValidationException.php4
-rw-r--r--lib/Service/StatusService.php19
-rw-r--r--lib/Settings/Admin.php8
-rw-r--r--lib/Settings/Section.php12
-rw-r--r--lib/Utility/OPMLExporter.php5
-rw-r--r--lib/Utility/PicoFeedClientFactory.php8
-rw-r--r--lib/Utility/PicoFeedFaviconFactory.php8
-rw-r--r--lib/Utility/ProxyConfigParser.php9
-rw-r--r--lib/Utility/Time.php5
-rw-r--r--lib/Utility/Updater.php14
63 files changed, 830 insertions, 755 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 9394e790b..d88bbbaec 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -31,7 +31,6 @@ use OCP\ILogger;
use PicoFeed\Config\Config as PicoFeedConfig;
use PicoFeed\Reader\Reader as PicoFeedReader;
-
class Application extends App
{
@@ -80,7 +79,6 @@ class Application extends App
}
});
-
$container->registerService(Config::class, function (IContainer $c): Config {
$config = new Config(
$c->query('ConfigView'),
@@ -168,8 +166,5 @@ class Application extends App
return $fetcher;
});
-
-
}
-
}
diff --git a/lib/Command/Updater/AfterUpdate.php b/lib/Command/Updater/AfterUpdate.php
index a9becf543..c80913fab 100644
--- a/lib/Command/Updater/AfterUpdate.php
+++ b/lib/Command/Updater/AfterUpdate.php
@@ -23,13 +23,13 @@ class AfterUpdate extends Command
{
private $updater;
- public function __construct(Updater $updater)
+ public function __construct(Updater $updater)
{
parent::__construct();
$this->updater = $updater;
}
- protected function configure()
+ protected function configure()
{
$this->setName('news:updater:after-update')
->setDescription(
@@ -38,9 +38,8 @@ class AfterUpdate extends Command
);
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output)
{
$this->updater->afterUpdate();
}
-
}
diff --git a/lib/Command/Updater/AllFeeds.php b/lib/Command/Updater/AllFeeds.php
index 8947c714e..21471379d 100644
--- a/lib/Command/Updater/AllFeeds.php
+++ b/lib/Command/Updater/AllFeeds.php
@@ -19,18 +19,17 @@ use Symfony\Component\Console\Output\OutputInterface;
use OCA\News\Service\FeedService;
-
class AllFeeds extends Command
{
private $feedService;
- public function __construct(FeedService $feedService)
+ public function __construct(FeedService $feedService)
{
parent::__construct();
$this->feedService = $feedService;
}
- protected function configure()
+ protected function configure()
{
$json = '{"feeds": [{"id": 39, "userId": "john"}, // etc ]}';
@@ -41,7 +40,7 @@ class AllFeeds extends Command
);
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output)
{
$feeds = $this->feedService->findAllFromAllUsers();
$result = ['feeds' => []];
@@ -55,5 +54,4 @@ class AllFeeds extends Command
print(json_encode($result));
}
-
}
diff --git a/lib/Command/Updater/BeforeUpdate.php b/lib/Command/Updater/BeforeUpdate.php
index 9d562d010..3a0b1ca72 100644
--- a/lib/Command/Updater/BeforeUpdate.php
+++ b/lib/Command/Updater/BeforeUpdate.php
@@ -23,13 +23,13 @@ class BeforeUpdate extends Command
{
private $updater;
- public function __construct(Updater $updater)
+ public function __construct(Updater $updater)
{
parent::__construct();
$this->updater = $updater;
}
- protected function configure()
+ protected function configure()
{
$this->setName('news:updater:before-update')
->setDescription(
@@ -39,9 +39,8 @@ class BeforeUpdate extends Command
);
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output)
{
$this->updater->beforeUpdate();
}
-
}
diff --git a/lib/Command/Updater/UpdateFeed.php b/lib/Command/Updater/UpdateFeed.php
index b07cc3e4a..f5cda22ad 100644
--- a/lib/Command/Updater/UpdateFeed.php
+++ b/lib/Command/Updater/UpdateFeed.php
@@ -20,18 +20,17 @@ use Symfony\Component\Console\Output\OutputInterface;
use OCA\News\Service\FeedService;
-
class UpdateFeed extends Command
{
private $feedService;
- public function __construct(FeedService $feedService)
+ public function __construct(FeedService $feedService)
{
parent::__construct();
$this->feedService = $feedService;
}
- protected function configure()
+ protected function configure()
{
$this->setName('news:updater:update-feed')
->addArgument(
@@ -47,7 +46,7 @@ class UpdateFeed extends Command
->setDescription('Console API for updating a single user\'s feed');
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output)
{
$feedId = $input->getArgument('feed-id');
$userId = $input->getArgument('user-id');
@@ -61,5 +60,4 @@ class UpdateFeed extends Command
);
}
}
-
}
diff --git a/lib/Config/Config.php b/lib/Config/Config.php
index 511582dbb..7c5cee74a 100644
--- a/lib/Config/Config.php
+++ b/lib/Config/Config.php
@@ -16,7 +16,6 @@ namespace OCA\News\Config;
use OCP\ILogger;
use OCP\Files\Folder;
-
class Config
{
@@ -34,7 +33,8 @@ class Config
private $maxSize;
private $exploreUrl;
- public function __construct(Folder $fileSystem,
+ public function __construct(
+ Folder $fileSystem,
ILogger $logger,
$LoggerParameters
) {
@@ -42,7 +42,7 @@ class Config
$this->autoPurgeMinimumInterval = 60;
$this->autoPurgeCount = 200;
$this->maxRedirects = 10;
- $this->maxSize = 100*1024*1024; // 100Mb
+ $this->maxSize = 100 * 1024 * 1024; // 100Mb
$this->feedFetcherTimeout = 60;
$this->useCronUpdates = true;
$this->logger = $logger;
@@ -50,7 +50,7 @@ class Config
$this->loggerParams = $LoggerParameters;
}
- public function getAutoPurgeMinimumInterval()
+ public function getAutoPurgeMinimumInterval()
{
if ($this->autoPurgeMinimumInterval > 60) {
return $this->autoPurgeMinimumInterval;
@@ -59,103 +59,100 @@ class Config
}
}
- public function getAutoPurgeCount()
+ public function getAutoPurgeCount()
{
return $this->autoPurgeCount;
}
- public function getMaxRedirects()
+ public function getMaxRedirects()
{
return $this->maxRedirects;
}
- public function getFeedFetcherTimeout()
+ public function getFeedFetcherTimeout()
{
return $this->feedFetcherTimeout;
}
- public function getUseCronUpdates()
+ public function getUseCronUpdates()
{
return $this->useCronUpdates;
}
- public function getMaxSize()
+ public function getMaxSize()
{
return $this->maxSize;
}
- public function getExploreUrl()
+ public function getExploreUrl()
{
return $this->exploreUrl;
}
- public function setAutoPurgeMinimumInterval($value)
+ public function setAutoPurgeMinimumInterval($value)
{
$this->autoPurgeMinimumInterval = $value;
}
- public function setAutoPurgeCount($value)
+ public function setAutoPurgeCount($value)
{
$this->autoPurgeCount = $value;
}
- public function setMaxRedirects($value)
+ public function setMaxRedirects($value)
{
$this->maxRedirects = $value;
}
- public function setFeedFetcherTimeout($value)
+ public function setFeedFetcherTimeout($value)
{
$this->feedFetcherTimeout = $value;
}
- public function setUseCronUpdates($value)
+ public function setUseCronUpdates($value)
{
$this->useCronUpdates = $value;
}
- public function setMaxSize($value)
+ public function setMaxSize($value)
{
$this->maxSize = $value;
}
- public function setExploreUrl($value)
+ public function setExploreUrl($value)
{
$this->exploreUrl = $value;
}
- public function read($configPath, $createIfNotExists=false)
+ public function read($configPath, $createIfNotExists = false)
{
- if($createIfNotExists && !$this->fileSystem->nodeExists($configPath)) {
+ if ($createIfNotExists && !$this->fileSystem->nodeExists($configPath)) {
$this->fileSystem->newFile($configPath);
$this->write($configPath);
-
} else {
-
$content = $this->fileSystem->get($configPath)->getContent();
$configValues = parse_ini_string($content);
- if($configValues === false || count($configValues) === 0) {
+ if ($configValues === false || count($configValues) === 0) {
$this->logger->warning(
'Configuration invalid. Ignoring values.',
$this->loggerParams
);
} else {
-
- foreach($configValues as $key => $value) {
- if(property_exists($this, $key)) {
+ foreach ($configValues as $key => $value) {
+ if (property_exists($this, $key)) {
$type = gettype($this->$key);
settype($value, $type);
$this->$key = $value;
@@ -167,13 +164,12 @@ class Config
);
}
}
-
}
}
}
- public function write($configPath)
+ public function write($configPath)
{
$ini =
'autoPurgeMinimumInterval = ' .
@@ -194,6 +190,4 @@ class Config
$this->fileSystem->get($configPath)->putContent($ini);
}
-
-
}
diff --git a/lib/Config/DependencyException.php b/lib/Config/DependencyException.php
index 4a6a168e3..6f9d21be6 100644
--- a/lib/Config/DependencyException.php
+++ b/lib/Config/DependencyException.php
@@ -26,6 +26,4 @@ class DependencyException extends \Exception
{
parent::__construct($msg);
}
-
-
-} \ No newline at end of file
+}
diff --git a/lib/Controller/AdminController.php b/lib/Controller/AdminController.php
index 7feff907b..3ce09a0d1 100644
--- a/lib/Controller/AdminController.php
+++ b/lib/Controller/AdminController.php
@@ -28,9 +28,9 @@ use OCA\News\Service\ItemService;
*/
class AdminController extends Controller
{
- private $_config;
- private $_configPath;
- private $_itemService;
+ private $config;
+ private $configPath;
+ private $itemService;
/**
* AdminController constructor.
@@ -41,13 +41,17 @@ class AdminController extends Controller
* @param ItemService $itemService Service for items
* @param string $configFile Path to the config
*/
- public function __construct($appName, IRequest $request, Config $config,
- ItemService $itemService, $configFile
+ public function __construct(
+ $appName,
+ IRequest $request,
+ Config $config,
+ ItemService $itemService,
+ $configFile
) {
parent::__construct($appName, $request);
- $this->_config = $config;
- $this->_configPath = $configFile;
- $this->_itemService = $itemService;
+ $this->config = $config;
+ $this->configPath = $configFile;
+ $this->itemService = $itemService;
}
/**
@@ -62,13 +66,13 @@ class AdminController extends Controller
{
$data = [
'autoPurgeMinimumInterval' =>
- $this->_config->getAutoPurgeMinimumInterval(),
- 'autoPurgeCount' => $this->_config->getAutoPurgeCount(),
- 'maxRedirects' => $this->_config->getMaxRedirects(),
- 'feedFetcherTimeout' => $this->_config->getFeedFetcherTimeout(),
- 'useCronUpdates' => $this->_config->getUseCronUpdates(),
- 'maxSize' => $this->_config->getMaxSize(),
- 'exploreUrl' => $this->_config->getExploreUrl(),
+ $this->config->getAutoPurgeMinimumInterval(),
+ 'autoPurgeCount' => $this->config->getAutoPurgeCount(),
+ 'maxRedirects' => $this->config->getMaxRedirects(),
+ 'feedFetcherTimeout' => $this->config->getFeedFetcherTimeout(),
+ 'useCronUpdates' => $this->config->getUseCronUpdates(),
+ 'maxSize' => $this->config->getMaxSize(),
+ 'exploreUrl' => $this->config->getExploreUrl(),
];
return new TemplateResponse($this->appName, 'admin', $data, 'blank');
}
@@ -87,29 +91,33 @@ class AdminController extends Controller
*
* @return array with the updated values
*/
- public function update($autoPurgeMinimumInterval, $autoPurgeCount,
- $maxRedirects, $feedFetcherTimeout, $maxSize,
- $useCronUpdates, $exploreUrl
+ public function update(
+ $autoPurgeMinimumInterval,
+ $autoPurgeCount,
+ $maxRedirects,
+ $feedFetcherTimeout,
+ $maxSize,
+ $useCronUpdates,
+ $exploreUrl
) {
- $this->_config->setAutoPurgeMinimumInterval($autoPurgeMinimumInterval);
- $this->_config->setAutoPurgeCount($autoPurgeCount);
- $this->_config->setMaxRedirects($maxRedirects);
- $this->_config->setMaxSize($maxSize);
- $this->_config->setFeedFetcherTimeout($feedFetcherTimeout);
- $this->_config->setUseCronUpdates($useCronUpdates);
- $this->_config->setExploreUrl($exploreUrl);
- $this->_config->write($this->_configPath);
+ $this->config->setAutoPurgeMinimumInterval($autoPurgeMinimumInterval);
+ $this->config->setAutoPurgeCount($autoPurgeCount);
+ $this->config->setMaxRedirects($maxRedirects);
+ $this->config->setMaxSize($maxSize);
+ $this->config->setFeedFetcherTimeout($feedFetcherTimeout);
+ $this->config->setUseCronUpdates($useCronUpdates);
+ $this->config->setExploreUrl($exploreUrl);
+ $this->config->write($this->configPath);
return [
'autoPurgeMinimumInterval' =>
- $this->_config->getAutoPurgeMinimumInterval(),
- 'autoPurgeCount' => $this->_config->getAutoPurgeCount(),
- 'maxRedirects' => $this->_config->getMaxRedirects(),
- 'maxSize' => $this->_config->getMaxSize(),
- 'feedFetcherTimeout' => $this->_config->getFeedFetcherTimeout(),
- 'useCronUpdates' => $this->_config->getUseCronUpdates(),
- 'exploreUrl' => $this->_config->getExploreUrl(),
+ $this->config->getAutoPurgeMinimumInterval(),
+ 'autoPurgeCount' => $this->config->getAutoPurgeCount(),
+ 'maxRedirects' => $this->config->getMaxRedirects(),
+ 'maxSize' => $this->config->getMaxSize(),
+ 'feedFetcherTimeout' => $this->config->getFeedFetcherTimeout(),
+ 'useCronUpdates' => $this->config->getUseCronUpdates(),
+ 'exploreUrl' => $this->config->getExploreUrl(),
];
}
-
}
diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php
index d2a787a28..68caf9236 100644
--- a/lib/Controller/ApiController.php
+++ b/lib/Controller/ApiController.php
@@ -40,7 +40,8 @@ class ApiController extends BaseApiController
* @param IRequest $request The request
* @param IUserSession $userSession The user session
*/
- public function __construct($appName, IRequest $request, IUserSession $userSession) {
+ public function __construct($appName, IRequest $request, IUserSession $userSession)
+ {
parent::__construct($appName, $request);
$this->userSession = $userSession;
}
@@ -48,14 +49,16 @@ class ApiController extends BaseApiController
/**
* @return IUser
*/