diff options
author | Joas Schilling <coding@schilljs.com> | 2018-01-11 10:59:10 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-01-15 09:55:03 +0100 |
commit | ffb3a3e33a2b0468a39ab9f11cf8f63f020bd0bb (patch) | |
tree | 79da8d3b535dfa79ffcdd5ccff712298e26ad3e8 /apps/updatenotification/lib/ResetTokenBackgroundJob.php | |
parent | 0f729e2cd375710890536f5968532879a3a7875d (diff) | |
download | nextcloud-server-ffb3a3e33a2b0468a39ab9f11cf8f63f020bd0bb.tar.gz nextcloud-server-ffb3a3e33a2b0468a39ab9f11cf8f63f020bd0bb.zip |
Improve ResetTokenBackgroundJob and unit test
* Automatic DI is implemented since 11
* Correctly type hint parameters
* Optimise the tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/updatenotification/lib/ResetTokenBackgroundJob.php')
-rw-r--r-- | apps/updatenotification/lib/ResetTokenBackgroundJob.php | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/apps/updatenotification/lib/ResetTokenBackgroundJob.php b/apps/updatenotification/lib/ResetTokenBackgroundJob.php index 93b5a750789..5dd7c4f35f1 100644 --- a/apps/updatenotification/lib/ResetTokenBackgroundJob.php +++ b/apps/updatenotification/lib/ResetTokenBackgroundJob.php @@ -22,7 +22,6 @@ namespace OCA\UpdateNotification; -use OC\AppFramework\Utility\TimeFactory; use OC\BackgroundJob\TimedJob; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; @@ -40,28 +39,15 @@ class ResetTokenBackgroundJob extends TimedJob { private $timeFactory; /** - * @param IConfig|null $config - * @param ITimeFactory|null $timeFactory + * @param IConfig $config + * @param ITimeFactory $timeFactory */ - public function __construct(IConfig $config = null, - ITimeFactory $timeFactory = null) { + public function __construct(IConfig $config, + ITimeFactory $timeFactory) { // Run all 10 minutes $this->setInterval(60 * 10); - - if ($config instanceof IConfig && $timeFactory instanceof ITimeFactory) { - $this->config = $config; - $this->timeFactory = $timeFactory; - } else { - $this->fixDIForJobs(); - } - } - - /** - * DI for jobs - */ - private function fixDIForJobs() { - $this->config = \OC::$server->getConfig(); - $this->timeFactory = new TimeFactory(); + $this->config = $config; + $this->timeFactory = $timeFactory; } /** |