diff options
author | Sean Molenaar <sean@m2mobi.com> | 2018-11-29 20:59:46 +0100 |
---|---|---|
committer | Sean Molenaar <sean@m2mobi.com> | 2018-12-14 07:54:43 +0100 |
commit | becce6b7520912257c3d72697a3aefec9923a467 (patch) | |
tree | a2e0da34df11ade7c630e9b681fac6d3b2383918 /lib | |
parent | 0f2645145ac31ad77788954c513f391bc4fbb295 (diff) |
Define an official codestyle and adhere to it.
Diffstat (limited to 'lib')
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, |