Completed
Push — master ( d62417...7b2aa5 )
by René
10:14 queued 11s
created

NotificationCron::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 6
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]>
4
 *
5
 * @author René Gieling <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Affero General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU Affero General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Polls\Cron;
25
26
use OCP\ILogger;
27
use OC\BackgroundJob\TimedJob;
0 ignored issues
show
Bug introduced by
The type OC\BackgroundJob\TimedJob was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
29
use OCA\Polls\Service\MailService;
30
31
class NotificationCron extends TimedJob {
32
33
	/** @var MailService*/
34
    private $mailService;
35
	private $logger;
36
37
	/** @param MailService $mailService
38
	*/
39
    public function __construct(
40
		ILogger $logger,
41
		MailService $mailService
42
	) {
43
		$this->logger = $logger;
44
		$this->setInterval(60);
45
		$this->mailService = $mailService;
46
    }
47
48
	/**
49
	* getByToken
50
	* Get pollId by token
51
	* @NoAdminRequired
52
	* @NoCSRFRequired
53
	* @PublicPage
54
	* @param string $token
55
	* @return DataResponse
0 ignored issues
show
Bug introduced by
The type OCA\Polls\Cron\DataResponse was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
56
	*/
57
    protected function run($arguments) {
58
        if ($this->mailService->sendNotifications()) {
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->mailService->sendNotifications() targeting OCA\Polls\Service\MailService::sendNotifications() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
59
        	$this->logger->debug('Notifications sent');
60
        } else {
61
			$this->logger->alert('error while sending notifications');
62
        }
63
    }
64
65
}
66